<template>
  <pageTabelLayout>
    <template #pageHeader>
      <div class="search-form divClass" v-if="headerShow">
        <div>
          <a-form
            size="small"
            :model="dataForm"
            layout="inline"
            label-align="right"
            v-if="
              (permissionStore.hasPermisson('tjpg.jjdqdcx') ||
                permissionStore.hasPermisson('tjpg.tjrwcx') ||
                permissionStore.hasPermisson('tjpg.tjshcx')) &&
              (tableId == 2 || tableId == 3 || tableId == 4)
            "
          >
            <a-form-item label="调机单号" :style="{ width: '310px' }" label-col-flex="90px">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.adjustmentCode"
                @press-enter="huiche"
              />
            </a-form-item>

            <a-form-item label="坯布编号" label-col-flex="90px" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.greyCode"
                @press-enter="huiche"
              />
            </a-form-item>

            <a-form-item label="坯布名称" label-col-flex="90px" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.grayName"
                @press-enter="huiche"
              />
            </a-form-item>

            <a-form-item label="织布单号" label-col-flex="90px" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.planOrderCode"
                @press-enter="huiche"
              />
            </a-form-item>

            <a-form-item label="生产单号" label-col-flex="90px" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.weaveCode"
                @press-enter="huiche"
              />
            </a-form-item>

            <a-form-item label-col-flex="90px" label="楼层" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.storey"
                @press-enter="huiche"
              />
            </a-form-item>

            <a-form-item
              label="开始日期"
              label-col-flex="90px"
              v-if="tableId == 2"
              :style="{ width: '310px' }"
            >
              <a-date-picker
                popup-container="html"
                class="bacClass"
                @press-enter="huiche"
                :style="{ width: '100%' }"
                v-model="pageData.empVerifyTimeStart"
              />
            </a-form-item>

            <a-form-item
              label="结束日期"
              label-col-flex="90px"
              v-if="tableId == 2"
              :style="{ width: '310px' }"
            >
              <a-date-picker
                popup-container="html"
                class="bacClass"
                @press-enter="huiche"
                :style="{ width: '100%' }"
                v-model="pageData.empVerifyTimeEnd"
              />
            </a-form-item>
            <a-form-item
              label="调机反馈开始"
              label-col-flex="90px"
              v-if="tableId == 3"
              :style="{ width: '310px' }"
            >
              <a-date-picker
                popup-container="html"
                class="bacClass"
                @press-enter="huiche"
                :style="{ width: '100%' }"
                v-model="pageData.empFeedBackTimeStart"
              />
            </a-form-item>
            <a-form-item
              label="调机反馈结束"
              label-col-flex="90px"
              v-if="tableId == 3"
              :style="{ width: '310px' }"
            >
              <a-date-picker
                popup-container="html"
                class="bacClass"
                @press-enter="huiche"
                :style="{ width: '100%' }"
                v-model="pageData.empFeedBackTimeEnd"
              />
            </a-form-item>
            <a-form-item
              label="交机开始日期"
              label-col-flex="90px"
              v-if="tableId == 3"
              :style="{ width: '310px' }"
            >
              <a-date-picker
                popup-container="html"
                class="bacClass"
                @press-enter="huiche"
                :style="{ width: '100%' }"
                v-model="pageData.empEndTimeStart"
              />
            </a-form-item>

            <a-form-item
              label="交机结束日期"
              label-col-flex="90px"
              v-if="tableId == 3"
              :style="{ width: '310px' }"
            >
              <a-date-picker
                popup-container="html"
                class="bacClass"
                @press-enter="huiche"
                :style="{ width: '100%' }"
                v-model="pageData.empEndTimeEnd"
              />
            </a-form-item>
            <a-form-item
              label="机台号"
              label-col-flex="90px"
              v-if="tableId == 1 || tableId == 3"
              :style="{ width: '310px' }"
            >
              <a-input allow-clear class="bacClass" placeholder="" v-model="pageData.machineCode" />
            </a-form-item>
            <a-form-item
              label="机台号"
              label-col-flex="90px"
              v-if="tableId == 2"
              :style="{ width: '310px' }"
            >
              <a-input allow-clear class="bacClass" placeholder="" v-model="pageData.machineCode" />
            </a-form-item>
            <a-form-item
              v-if="tableId == 2"
              label="状态"
              label-col-flex="90px"
              :style="{ width: '310px' }"
            >
              <a-select
                popup-container="html"
                allow-clear
                class="bacClass"
                placeholder="全部"
                v-model="pageData.tjrwCode"
                @press-enter="huiche"
              >
                <a-option value="已查布头">已查布头&nbsp;&nbsp;</a-option>
                <a-option value="已派工">已派工</a-option>
                <a-option value="未派工">未派工</a-option>
                <a-option value="调机中">调机中</a-option>
                <a-option value="已反馈">已反馈</a-option>
                <a-option value="已交机">已交机</a-option>
              </a-select>
            </a-form-item>
            <a-form-item
              label="机台号"
              label-col-flex="90px"
              v-if="tableId == 4"
              :style="{ width: '310px' }"
            >
              <a-input allow-clear class="bacClass" placeholder="" v-model="pageData.machineCode" />
            </a-form-item>
          </a-form>
          <a-form
            size="small"
            :model="pageData"
            layout="inline"
            label-align="right"
            v-if="tableId == 1 && permissionStore.hasPermisson('tjpg.tjdqdcx')"
          >
            <a-form-item label-col-flex="90px" label="楼层" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.storey"
                @press-enter="huiche"
              />
            </a-form-item>
            <a-form-item label="调机单号" label-col-flex="90px" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.adjustmentCode"
                @press-enter="huiche"
              />
            </a-form-item>
            <a-form-item label="坯布编号" label-col-flex="90px" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.greyCode"
                @press-enter="huiche"
              />
            </a-form-item>
            <a-form-item label="坯布名称" label-col-flex="90px" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.grayName"
                @press-enter="huiche"
              />
            </a-form-item>
            <a-form-item label="织布单号" label-col-flex="90px" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.planOrderCode"
                @press-enter="huiche"
              />
            </a-form-item>
            <a-form-item label="生产单号" label-col-flex="90px" :style="{ width: '310px' }">
              <a-input
                allow-clear
                class="bacClass"
                placeholder=""
                v-model="pageData.weaveCode"
                @press-enter="huiche"
              />
            </a-form-item>
            <a-form-item label="开始日期" label-col-flex="90px" :style="{ width: '310px' }">
              <a-date-picker
                popup-container="html"
                class="bacClass"
                @press-enter="huiche"
                :style="{ width: '100%' }"
                v-model="pageData.dateStart"
              />
            </a-form-item>
            <a-form-item label="结束日期" label-col-flex="90px" :style="{ width: '310px' }">
              <a-date-picker
                popup-container="html"
                class="bacClass"
                @press-enter="huiche"
                :style="{ width: '100%' }"
                v-model="pageData.dateEnd"
              />
            </a-form-item>
            <a-form-item label="机台号" label-col-flex="90px" :style="{ width: '310px' }">
              <a-input allow-clear class="bacClass" placeholder="" v-model="pageData.machineCode" />
            </a-form-item>
          </a-form>
        </div>
      </div>
      <div class="my-divisders">
        <a-divider orientation="center">
          <icon-double-up
            v-if="headerShow"
            @click="headerShow = false"
            :strokeWidth="2"
            :size="18"
          />
          <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
        </a-divider>
      </div>
      <div class="my-tool-bar">
        <Toolbar
          :items="pageData.btnList"
          @add="insertHandleClick"
          @select="selectHandler"
          @dispatch="handleClick(1)"
          @checkInMonitor="checkInMonitor"
          @audit="auditData"
          @sendSwitch="sendSwitch"
        >
        </Toolbar>
      </div>
    </template>
    <template #pageTabel>
      <a-tabs
        @change="changeTabs"
        :justify="true"
        :default-active-key="pageData1.tableIndex"
        style="height: 100%"
      >
        <a-tab-pane title="调机待确认" key="1">
          <a-spin
            :loading="pageData.pageLoading"
            tip="加载中"
            dot
            style="height: 100%; width: 100%; z-index: 999"
          >
            <AgGridVuesCopys
              :rowHeight="33"
              :headerHeight="33"
              :suppressCopyRowsToClipboard="true"
              :suppressDragLeaveHidesColumns="true"
              rowSelection="multiple"
              @grid-ready="gridReady4"
              @columnResized="onColumnResized4"
              @columnMoved="onColumnMoved4"
              @columnVisible="onColumnVisible4"
              @SelectionChanged="aggridFs4.clickAllSelectors"
              @FilterChanged="aggridFs4.onFilterChanged"
              style="height: calc(100% - 45px)"
              :defaultColDef="defaultColDef4"
              class="ag-theme-alpine"
              :rowData="table.dataList"
              :columnDefs="tc4"
              :localeText="localeText1"
            >
            </AgGridVuesCopys>
            <paginationCopys
              v-if="tableId == 1"
              :total="paginations1.total"
              show-total
              show-jumper
              show-page-size
              :page-size="paginations1.pageSize"
              :current="paginations1.page"
              @change="PageSize"
              @page-size-change="change1"
              style="justify-content: center"
              :page-size-options="pagingList1"
            />
          </a-spin>
        </a-tab-pane>
        <a-tab-pane title="交机待确认" key="3">
          <a-spin
            :loading="pageData.pageLoading"
            tip="加载中"
            dot
            style="height: 100%; width: 100%; z-index: 999"
          >
            <AgGridVuesCopys
              :rowHeight="33"
              :headerHeight="33"
              :suppressCopyRowsToClipboard="true"
              :suppressDragLeaveHidesColumns="true"
              rowSelection="multiple"
              @grid-ready="gridReady2"
              @SelectionChanged="aggridFs2.clickAllSelectors"
              @FilterChanged="aggridFs2.onFilterChanged"
              @columnResized="onColumnResized2"
              @columnMoved="onColumnMoved2"
              @columnVisible="onColumnVisible2"
              style="height: calc(100% - 45px)"
              :defaultColDef="defaultColDef2"
              class="ag-theme-alpine"
              :rowData="table.dataList"
              :columnDefs="tc2"
              :localeText="localeText1"
            >
            </AgGridVuesCopys>
            <paginationCopys
              v-if="tableId == 2 || tableId == 3 || tableId == 4"
              :total="pagination.total"
              show-total
              show-jumper
              show-page-size
              @change="PageSize"
              @page-size-change="change1"
              style="justify-content: center"
              :page-size="pagination.pageSize"
              :current="pagination.page"
              :page-size-options="pagingList1"
            />
          </a-spin>
        </a-tab-pane>
        <a-tab-pane title="调机任务" key="2">
          <a-spin
            :loading="pageData.pageLoading"
            tip="加载中"
            dot
            style="height: 100%; width: 100%; z-index: 999"
          >
            <AgGridVuesCopys
              :rowHeight="33"
              :headerHeight="33"
              :suppressCopyRowsToClipboard="true"
              :suppressDragLeaveHidesColumns="true"
              rowSelection="multiple"
              @grid-ready="gridReady"
              @SelectionChanged="aggridFs.clickAllSelectors"
              @FilterChanged="aggridFs.onFilterChanged"
              @columnResized="onColumnResized"
              @columnMoved="onColumnMoved"
              @columnVisible="onColumnVisible"
              style="height: calc(100% - 45px)"
              :defaultColDef="defaultColDef"
              class="ag-theme-alpine"
              :rowData="table.dataList"
              :columnDefs="tc1"
              :localeText="localeText1"
            >
            </AgGridVuesCopys>
            <paginationCopys
              v-if="tableId == 2 || tableId == 3 || tableId == 4"
              :total="pagination.total"
              show-total
              show-jumper
              show-page-size
              @change="PageSize"
              @page-size-change="change1"
              style="justify-content: center"
              :page-size="pagination.pageSize"
              :current="pagination.page"
              :page-size-options="pagingList1"
            />
          </a-spin>
        </a-tab-pane>
        <a-tab-pane title="调机审核" key="4">
          <a-spin
            :loading="pageData.pageLoading"
            tip="加载中"
            dot
            style="height: 100%; width: 100%; z-index: 999"
          >
            <AgGridVuesCopys
              :rowHeight="33"
              :headerHeight="33"
              :suppressCopyRowsToClipboard="true"
              :suppressDragLeaveHidesColumns="true"
              rowSelection="multiple"
              @grid-ready="gridReady5"
              @SelectionChanged="aggridFs5.clickAllSelectors"
              @FilterChanged="aggridFs5.onFilterChanged"
              @columnResized="onColumnResized5"
              @columnMoved="onColumnMoved5"
              @columnVisible="onColumnVisible5"
              style="height: calc(100% - 45px)"
              :defaultColDef="defaultColDef5"
              class="ag-theme-alpine"
              :rowData="table.dataList"
              :columnDefs="tc5"
              :localeText="localeText1"
            >
            </AgGridVuesCopys>
            <paginationCopys
              v-if="tableId == 2 || tableId == 3 || tableId == 4"
              :total="pagination.total"
              show-total
              show-jumper
              show-page-size
              @change="PageSize"
              @page-size-change="change1"
              style="justify-content: center"
              :page-size="pagination.pageSize"
              :current="pagination.page"
              :page-size-options="pagingList1"
            />
          </a-spin>
        </a-tab-pane>
      </a-tabs>
    </template>
    <a-drawer
      style="z-index: 999"
      ok-text="保存"
      cancel-text="关闭"
      :drawer-style="{ zIndex: 999 }"
      :mask-closable="false"
      :width="400"
      :visible="pageData.showAdd"
      unmountOnClose
      @ok="sideOk"
      @cancel="pageData.showAdd = false"
    >
      <template #title>
        {{ pageData.sideTitle }}
      </template>
      <div>
        <a-form ref="formRef" layout="horizontal" :model="pageData">
          <div v-for="(item, index) in pageData.editYgTime" :key="index"
            >-
            <div style="width: 100%">
              <span style="margin-right: 20px">员工名称</span>
              <div style="margin-bottom: 10px; display: inline-block; width: 250px">
                <a-input
                  class="bacClass"
                  v-model="item['employeeName']"
                  disabled
                  style="width: 100%"
                />
              </div>
              <br />
              <span style="margin-right: 20px">开始时间</span>
              <div style="margin-bottom: 10px; display: inline-block; width: 250px">
                <a-date-picker
                  popup-container="html"
                  class="bacClass"
                  v-model="item['adjustmentStartDate']"
                  :defaultValue="pageData.NowDate"
                  style="width: 100%"
                />
              </div>
              <br />
              <span style="margin-right: 20px">完成时间</span>
              <div style="margin-bottom: 10px; display: inline-block; width: 250px">
                <a-date-picker
                  popup-container="html"
                  class="bacClass"
                  v-model="item['adjustmentEndDate']"
                  :defaultValue="pageData.NowDate"
                  style="width: 100%"
                />
              </div>
            </div>
          </div>
        </a-form>
      </div>
    </a-drawer>
    <a-modal
      v-model:visible="visibleZdfb"
      title="转单发布"
      @cancel="handleCancelZdfb"
      style="z-index: 1000"
      :draggable="true"
      @ok="handleOkZdfb"
    >
      <div class="flex">
        <div class="w-[50%] text-end leading-[30px] text-lg">调机类型变成转单,请选择：</div>
        <!-- <CorporateSectorCascader ref="cascaderRef" :configCascader="configCascader" @changeCascader="changeCascader" /> -->

        <a-radio-group v-model="typeZdfb" class="w-[50%] text-xl">
          <a-radio :value="0" class="text-lg">转单查布头</a-radio>
          <a-radio :value="1" class="text-lg">转单工艺复核</a-radio>
        </a-radio-group>
      </div>
    </a-modal>
    <!--调机任务点击修改弹窗 -->
    <a-modal
      v-model:visible="visible"
      title=""
      :draggable="true"
      :loading="modalLoading"
      width="1300px"
      style="z-index: 999"
      @close="handleDrawerClose"
      :on-before-ok="handleBeforeOk"
      :mask-closable="true"
    >
      <a-form
        size="mini"
        :model="pageData.adjustment"
        layout="inline"
        label-align="right"
        ref="formRef1"
      >
        <a-form-item
          label="调机单号"
          :style="{ width: '260px' }"
          v-if="insertType == 1"
          label-col-flex="90px"
        >
          <a-input v-model="pageData.adjustment['adjustmentCode']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item
          label="机台号"
          :style="{ width: '300px' }"
          :rules="[{ required: true, message: '机台号必填' }]"
          :validate-trigger="['blur']"
          field="machineCode"
          label-col-flex="90px"
        >
          <a-input
            v-if="insertType == 1 || pageData.isXq"
            v-model="pageData.adjustment['machineCode']"
            disabled
            class="bacClass"
          />
          <a-select
            popup-container="html"
            v-else
            :loading="loading"
            class="bacClass"
            v-model="pageData.adjustment['machineCode']"
            :filter-option="false"
            allow-search
            allow-clear
            @search="searchMachine"
            @change="changeMachine"
            :disabled="tiaoJiXianZhi"
          >
            <a-option v-for="item in pageData.machineList" :value="item['machineCode']"
              >{{ item['machineCode'] }}——{{ item['machineName'] }}
            </a-option>
          </a-select>
        </a-form-item>
        <a-form-item
          label="调机开始时间"
          :style="{ width: '270px' }"
          :rules="[{ required: true, message: '调机开始时间必填' }]"
          :validate-trigger="['blur']"
          field="startTime"
          label-col-flex="110px"
        >
          <a-date-picker
            popup-container="html"
            v-model="pageData.adjustment['startTime']"
            :disabled="insertType == 1 || pageData.isXq || tiaoJiXianZhi"
            format="YYYY-MM-DD HH:mm:ss"
            :class="{ timeClass: insertType != 1 }"
            show-time
            class="bacClass"
          />
        </a-form-item>

        <a-form-item label="调机结束时间" :style="{ width: '270px' }" label-col-flex="90px">
          <a-date-picker
            popup-container="html"
            v-model="pageData.adjustment['endTime']"
            :disabled="insertType == 1 || pageData.isXq || tiaoJiXianZhi"
            format="YYYY-MM-DD HH:mm:ss"
            :class="{ timeClass: insertType != 1 }"
            show-time
            class="bacClass"
          />
        </a-form-item>

        <a-form-item label="是否抽针" :style="{ width: '260px' }" label-col-flex="90px">
          <a-select
            popup-container="html"
            class="bacClass"
            v-model="pageData.adjustment['drawnNeedleState']"
            :allow-clear="true"
            disabled
          >
            <a-option :value="0">抽针</a-option>
            <a-option :value="1">圆筒</a-option>
          </a-select>
        </a-form-item>

        <a-form-item label="织布单号" :style="{ width: '300px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['planOrderCode']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item label="生产单号" :style="{ width: '270px' }" label-col-flex="90px">
          <a-input
            v-model="pageData.adjustment['weaveCode']"
            class="bacClass"
            v-if="isDispatchWorkDetail"
            disabled
          />
          <a-select
            popup-container="html"
            :style="{ width: '210px' }"
            :loading="loading"
            class="bacClass"
            v-model="pageData.adjustment['weaveCode']"
            :filter-option="false"
            allow-clear
            v-if="!isDispatchWorkDetail"
            @change="handleWeaveCodeChange"
          >
            <a-option v-for="item in pageData.weaveCodeList" :value="item['weaveCode']"
              >{{ item['weaveCode'] }}
            </a-option>
          </a-select>
        </a-form-item>

        <a-form-item label="楼层" :style="{ width: '270px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['storey']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item label="取样员" :style="{ width: '260px' }" label-col-flex="90px">
          <a-input
            v-model="pageData.adjustment['sampleStaff']"
            readonly
            @click="cxTable(0)"
            placeholder="点击选员工"
            class="bacClass"
            :disabled="pageData.isXq || tiaoJiXianZhi"
          />
        </a-form-item>

        <a-form-item label="客户名称" :style="{ width: '300px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['customName']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item label="坯布编号" :style="{ width: '270px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['greyCode']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item label="坯布名称" :style="{ width: '270px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['grayName']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item label="调机布重量" :style="{ width: '260px' }" label-col-flex="90px">
          <a-input-number
            v-model="pageData.adjustment['adjustmentWeight']"
            class="input-demo bacClass"
            :min="0"
            :disabled="pageData.isXq || tiaoJiXianZhi"
            :max="1000000000000000"
          />
        </a-form-item>

        <a-form-item label="取样布重量" :style="{ width: '300px' }" label-col-flex="90px">
          <a-input-number
            v-model="pageData.adjustment['sampleWeight']"
            class="input-demo bacClass"
            :min="0"
            :disabled="pageData.isXq || tiaoJiXianZhi"
            :max="10000000000000000"
          />
        </a-form-item>

        <a-form-item label="是否开幅" :style="{ width: '270px' }" label-col-flex="90px">
          <a-select
            popup-container="html"
            class="bacClass"
            v-model="pageData.adjustment['widthState']"
            :allow-clear="true"
            disabled
          >
            <a-option :value="0">开幅</a-option>
            <a-option :value="1">不开幅</a-option>
          </a-select>
        </a-form-item>

        <a-form-item label="折扣比例(%)" :style="{ width: '270px' }" label-col-flex="90px">
          <a-input-number
            v-model="pageData.adjustment['adjustmentRatio']"
            class="input-demo bacClass"
            :min="0"
            :max="100"
            :disabled="pageData.isXq"
          />
        </a-form-item>

        <!-- <a-col :span="6">
            <a-form-item label="操作日期" :style="{ width: '250px' }">
              <a-date-picker  popup-container="html"  v-model="adjustment['lastTimeMaintainDate']" style="width: 200px" disabled />
            </a-form-item>
          </a-col> -->

        <a-form-item
          label="调机类型"
          :style="{ width: '260px' }"
          :rules="[{ required: true, message: '调机类型必填' }]"
          :validate-trigger="['blur']"
          field="maintainType"
          label-col-flex="90px"
        >
          <a-select
            popup-container="html"
            class="bacClass"
            v-model="pageData.adjustment['maintainType']"
            :allow-clear="true"
            @change="changeJx"
            :disabled="tiaoJiXianZhi2"
          >
            <a-option v-for="item in pageData.maintainTypeList" :value="item['machineTypeName']">
              {{ item['machineTypeName'] }}
            </a-option>
          </a-select>
        </a-form-item>

        <a-form-item
          label="最后调机类型"
          :style="{ width: '300px' }"
          field="lastTimeMaintainType"
          label-col-flex="90px"
        >
          <a-input
            v-model="pageData.adjustment['lastTimeMaintainType']"
            disabled
            class="bacClass"
          />
        </a-form-item>
        <a-form-item
          label="机台设备Id"
          :style="{ width: '270px' }"
          field="machineId"
          label-col-flex="90px"
        >
          <a-input v-model="pageData.adjustment['machineId']" disabled class="bacClass" />
        </a-form-item>
        <a-form-item
          label="折扣单价"
          :style="{ width: '270px' }"
          field="discountPrice"
          label-col-flex="90px"
          v-if="pageData.isXq"
        >
          <a-input v-model="pageData.adjustment['discountPrice']" disabled class="bacClass" />
        </a-form-item>
      </a-form>
      <div style="width: 100%; border: 1px solid #ccc; height: 400px; overflow: auto">
        <div
          style="display: inline-block; width: 49%; height: 100%; vertical-align: top; padding: 5px"
        >
          <!-- <div v-if="!tiaoJiXianZhi3"> -->
          <div>
            <a-button type="primary" @click="cxTable(1)" size="mini" v-if="pageData.isXq1"
              >选择派工人员
            </a-button>
          </div>

          <div style="width: 100%; height: 35%; overflow: auto">
            <table class="Table" style="margin: 0px auto">
              <thead>
                <tr>
                  <td class="thClass" v-if="!tiaoJiXianZhi3">操作</td>
                  <td class="thClass">员工名称</td>
                  <td class="thClass">分配</td>
                  <td class="thClass" v-if="pageData.isXq">分配金额</td>
                </tr>
              </thead>
              <tbody>
                <tr v-for="(item, index) in pageData.checkRyList" :key="index">
                  <td style="font-size: 20px; cursor: pointer" v-if="!tiaoJiXianZhi3">
                    <icon-delete @click="delRow(item['id'])" v-if="!pageData.isXq" />
                  </td>
                  <td>{{ item['employeeName'] }}</td>
                  <td>
                    <a-input-number
                      v-model="item['ratio']"
                      style="height: 30px; width: 80px"
                      class="input-demo bacClass"
                      :min="0"
                      :max="100"
                      @change="changeRatio(item)"
                      :disabled="pageData.isXq"
                    />
                  </td>
                  <td v-if="pageData.isXq">{{ item['allocationAmount'].toFixed(2) }}</td>
                </tr>
              </tbody>
            </table>
          </div>
          <div v-for="picPath in pictures" class="flex w-full overflow-hidden flex-wrap">
            <a-image
              :src="baseURL + '/minio/file/download/zzy/' + picPath.pictureAddres"
              style="width: 80px; height: 120px; margin: 5px 5px"
              fit="fill"
              show-loader
            />
          </div>
        </div>
        <div style="display: inline-block; width: 50%">
          <table class="Table" style="margin: 0 auto; margin-top: 30px">
            <thead>
              <tr>
                <td class="thClass">调机项目</td>
                <td class="thClass">标准</td>
                <td class="thClass">调整</td>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>布架宽度</td>
                <td>{{ itemsoB1['clothRackWidth'] }}</td>
                <td>
                  <!-- <a-input class="bacClass" v-model="itemsoB['clothRackWidth']"
                  :disabled="pageData.isXq || tiaoJiXianZhi" /> -->
                  <a-input
                    class="bacClass"
                    v-model="itemsoB['clothRackWidth']"
                    :disabled="pageData.isXq"
                  />
                </td>
              </tr>
              <tr>
                <td>织针型号</td>
                <td>{{ itemsoB1['needleModel'] }}</td>
                <td>
                  <!-- <a-select popup-container="html"  v-model="itemsoB['needleModel']" class="bacClass" allow-clear>
                  <a-option :value="0"></a-option>
                  <a-option :value="1">√</a-option>
                </a-select> -->
                <a-input v-model="itemsoB['needleModel']"  class="bacClass"
                :style="{ width: '210px' }" popup-container="html" allow-clear></a-input>
                </td>
              </tr>
              <tr>
                <td>织针1段</td>
                <td>{{ itemsoB1['needleOnePerod'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['needleOnePerod']"
                    class="bacClass"
                    allow-clear
                    :disabled="pageData.isXq"
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>织针2段</td>
                <td>{{ itemsoB1['needleTwoPerod'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['needleTwoPerod']"
                    class="bacClass"
                    allow-clear
                    :disabled="pageData.isXq"
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>织针3段</td>
                <td>{{ itemsoB1['needleThreePerod'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['needleThreePerod']"
                    class="bacClass"
                    allow-clear
                    :disabled="pageData.isXq"
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>织针4段</td>
                <td>{{ itemsoB1['needleFourPerod'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['needleFourPerod']"
                    class="bacClass"
                    allow-clear
                    :disabled="pageData.isXq"
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>争食</td>
                <td>{{ itemsoB1['dodge'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['dodge']"
                    class="bacClass"
                    allow-clear
                    :disabled="pageData.isXq"
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>分食</td>
                <td>{{ itemsoB1['broken'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['broken']"
                    class="bacClass"
                    allow-clear
                    :disabled="pageData.isXq"
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>不争不分</td>
                <td>{{ itemsoB1['allTrue'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['allTrue']"
                    class="bacClass"
                    allow-clear
                    :disabled="pageData.isXq"
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>布加张力A-D</td>
                <td>{{ itemsoB1['clothTensionAD'] }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['clothTensionAD']"
                    class="bacClass"
                    allow-clear
                    :disabled="pageData.isXq"
                  >
                    <a-option value="A">A</a-option>
                    <a-option value="B">B</a-option>
                    <a-option value="C">C</a-option>
                    <a-option value="D">D</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>布加张力1-16</td>
                <td>{{ itemsoB1['clothTensionOS'] }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['clothTensionOS']"
                    class="bacClass"
                    allow-clear
                    :disabled="pageData.isXq"
                  >
                    <a-option :value="1">1</a-option>
                    <a-option :value="2">2</a-option>
                    <a-option :value="3">3</a-option>
                    <a-option :value="4">4</a-option>
                    <a-option :value="5">5</a-option>
                    <a-option :value="6">6</a-option>
                    <a-option :value="7">7</a-option>
                    <a-option :value="8">8</a-option>
                    <a-option :value="9">9</a-option>
                    <a-option :value="10">10</a-option>
                    <a-option :value="11">11</a-option>
                    <a-option :value="12">12</a-option>
                    <a-option :value="13">13</a-option>
                    <a-option :value="14">14</a-option>
                    <a-option :value="15">15</a-option>
                    <a-option :value="16">16</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>底座垫片</td>
                <td>{{ itemsoB1['baseGasket'] }}</td>
                <td>
                  <a-input
                    class="bacClass"
                    v-model="itemsoB['baseGasket']"
                    :disabled="pageData.isXq"
                  />
                </td>
              </tr>
              <tr>
                <td>送纱盘-中盘</td>
                <td>{{ itemsoB1['sandTrayMiddlePlate'] }}</td>
                <td>
                  <a-input-number
                    class="bacClass"
                    v-model="itemsoB['sandTrayMiddlePlate']"
                    :disabled="pageData.isXq"
                  />
                </td>
              </tr>
              <tr>
                <td>送纱盘-面盘</td>
                <td>{{ itemsoB1['sandTableSurfacePlate'] }}</td>
                <td>
                  <a-input-number
                    class="bacClass"
                    v-model="itemsoB['sandTableSurfacePlate']"
                    :disabled="pageData.isXq"
                  />
                </td>
              </tr>
              <tr>
                <td>送沙盘-底盘</td>
                <td>{{ itemsoB1['sandDownSurfacePlate'] }}</td>
                <td>
                  <a-input-number
                    class="bacClass"
                    v-model="itemsoB['sandDownSurfacePlate']"
                    :disabled="pageData.isXq"
                  />
                </td>
              </tr>
              <tr>
                <td>齿轮</td>
                <td>{{ itemsoB1['gear'] }}</td>
                <td>
                  <a-input class="bacClass" v-model="itemsoB['gear']" :disabled="pageData.isXq" />
                </td>
              </tr>
              <tr>
                <td>机速</td>
                <td>{{ itemsoB1['engineSpeed'] }}</td>
                <td>
                  <a-input-number
                    v-model="itemsoB['engineSpeed']"
                    placeholder=""
                    class="bacClass"
                    :min="0"
                    :disabled="pageData.isXq"
                    :max="1000000000000"
                    :precision="2"
                  />
                </td>
              </tr>
              <tr>
                <td>油速</td>
                <td>{{ itemsoB1['oilVelocity'] }}</td>
                <td>
                  <a-input
                    v-model="itemsoB['oilVelocity']"
                    placeholder=""
                    class="bacClass"
                    :disabled="pageData.isXq"
                  />
                </td>
              </tr>
              <tr>
                <td>实开路数</td>
                <td>{{ itemsoB1['actualOpenWay'] }}</td>
                <td>
                  <a-input
                    v-model="itemsoB['actualOpenWay']"
                    placeholder=""
                    class="bacClass"
                    :disabled="pageData.isXq"
                  />
                </td>
              </tr>
              <tr>
                <td>针叶型号</td>
                <td>{{ itemsoB1['needleModelNo'] }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    class="bacClass"
                    v-model="itemsoB['needleModelNo']"
                    @click="needleMpdelClick('')"
                    @search="needleMpdelClick"
                    allow-clear
                    allow-search
                  >
                    <a-option v-for="item in needleMpdelList" :value="item.specName">
                      {{ item.specName }}
                    </a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>筒高</td>
                <td>{{ itemsoB1['needleModelNo'] }}</td>
                <td>
                  <a-input-number v-model="itemsoB['barrelHeight']" class="bacClass" :min="0" allow-clear :precision="0" />
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>

      <!-- <template #footer>
        <a-button type="primary" @click="handleBeforeOk" size="mini" v-if="!pageData.isXq" :loading="modalLoading"
          >保存
        </a-button>
        <a-button size="mini" @click="handleCancel">关闭</a-button>
      </template> -->
    </a-modal>
    <!-- 指派机器人弹窗 -->
    <a-modal
      v-model:visible="visible1"
      title="指派调机人"
      @cancel="handleCancel1"
      style="z-index: 1000"
      :draggable="true"
      @ok="handleOk"
    >
      <a-form :model="pageData" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }">
        <!-- <CorporateSectorCascader ref="cascaderRef" :configCascader="configCascader" @changeCascader="changeCascader" /> -->
        <a-form-item field="ygName" label="员工">
          <a-select
            popup-container="html"
            class="bacClass"
            v-model="pageData.ygName"
            @focus="getYgName"
            :loading="loading6"
            @search="handleSearch6"
            :filter-option="false"
            allow-search
            allow-clear
          >
            <a-option v-for="(item, index) in pageData.ygNameList" :key="index" :value="item['id']">
              {{ item['name'] }}
            </a-option>
          </a-select>
        </a-form-item>
      </a-form>
    </a-modal>
    <!-- 打印派工单弹窗 -->
    <a-modal
      v-model:visible="visible2"
      title="打印派工单"
      ok-text="打印"
      :draggable="true"
      @cancel="handleCancel2"
      @ok="printOk"
      width="750px"
    >
      <div id="spediz">
        <div style="width: 49%; display: inline-block; vertical-align: top">
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">调机单号：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['adjustmentCode'] }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">调机开始时间：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['startTime'] }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">调机结束时间：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['endTime'] }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">是否抽针：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['endTdrawnNeedleStateime'] == 0 ? '是' : '否' }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">织布单号</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['planOrderCode'] }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">织造序号：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['weaveCode'] }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">取样员：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['sampleStaff'] }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">坯布编号：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['greyCode'] }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">坯布名称：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['grayName'] }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">调机布重量：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['adjustmentWeight'] }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">取样布重量：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['sampleWeight'] }}
            </div>
          </div>
          <div
            style="
              display: inline-block;
              margin-left: 20px;
              vertical-align: top;
              margin-bottom: 10px;
            "
          >
            <span class="spanClass">是否开幅：</span>
            <div
              style="
                width: 200px;
                height: 30px;
                border: 1px solid #ccc;
                line-height: 30px;
                display: inline-block;
                vertical-align: top;
              "
            >
              {{ pageData.adjustment['widthState'] == 0 ? '是' : '否' }}
            </div>
          </div>
        </div>
        <div style="display: inline-block; width: 49%">
          <table class="Table" style="margin: 0 auto; vertical-align: top">
            <thead>
              <tr>
                <td class="thClass">调机项目</td>
                <td class="thClass">标准</td>
                <td class="thClass">调整</td>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>布架宽度</td>
                <td>{{ itemsoB['clothRackWidth'] }}</td>
                <td>
                  {{ itemsoB['clothRackWidth'] }}
                </td>
              </tr>
              <tr>
                <td>织针型号</td>
                <td>{{ itemsoB['needleModel'] }}</td>
                <td>
                  {{ itemsoB['needleModel'] }}
                </td>
              </tr>
              <tr>
                <td>织针1段</td>
                <td>{{ itemsoB['needleOnePerod'] }}</td>
                <td>
                  {{ itemsoB['needleOnePerod'] }}
                </td>
              </tr>
              <tr>
                <td>织针2段</td>
                <td>{{ itemsoB['needleTwoPerod'] }}</td>
                <td>
                  {{ itemsoB['needleTwoPerod'] }}
                </td>
              </tr>
              <tr>
                <td>织针3段</td>
                <td>{{ itemsoB['needleThreePerod'] }}</td>
                <td>
                  {{ itemsoB['needleThreePerod'] }}
                </td>
              </tr>
              <tr>
                <td>织针4段</td>
                <td>{{ itemsoB['needleFourPerod'] }}</td>
                <td>
                  {{ itemsoB['needleFourPerod'] }}
                </td>
              </tr>
              <tr>
                <td>争食</td>
                <td>{{ itemsoB['dodge'] }}</td>
                <td>
                  {{ itemsoB['dodge'] }}
                </td>
              </tr>
              <tr>
                <td>分食</td>
                <td>{{ itemsoB['broken'] }}</td>
                <td>
                  {{ itemsoB['broken'] }}
                </td>
              </tr>
              <tr>
                <td>不争不分</td>
                <td>{{ itemsoB['allTrue'] }}</td>
                <td>
                  {{ itemsoB['allTrue'] }}
                </td>
              </tr>
              <tr>
                <td>布加张力A-D</td>
                <td>{{ itemsoB['clothTensionAD'] }}</td>
                <td>
                  {{ itemsoB['clothTensionAD'] }}
                </td>
              </tr>
              <tr>
                <td>布加张力1-16</td>
                <td>{{ itemsoB['clothTensionOS'] }}</td>
                <td>
                  {{ itemsoB['clothTensionOS'] }}
                </td>
              </tr>
              <tr>
                <td>底座垫片</td>
                <td>{{ itemsoB['baseGasket'] }}</td>
                <td>
                  {{ itemsoB['baseGasket'] }}
                </td>
              </tr>
              <tr>
                <td>送纱盘-中盘</td>
                <td>{{ itemsoB['sandTrayMiddlePlate'] }}</td>
                <td>
                  {{ itemsoB['sandTrayMiddlePlate'] }}
                </td>
              </tr>
              <tr>
                <td>送纱盘-面盘</td>
                <td>{{ itemsoB['sandTableSurfacePlate'] }}</td>
                <td>
                  {{ itemsoB['sandTableSurfacePlate'] }}
                </td>
              </tr>
              <tr>
                <td>齿轮</td>
                <td>{{ itemsoB['gear'] }}</td>
                <td>
                  {{ itemsoB['gear'] }}
                </td>
              </tr>
              <tr>
                <td>机速</td>
                <td>{{ itemsoB['engineSpeed'] }}</td>
                <td>
                  {{ itemsoB['engineSpeed'] }}
                </td>
              </tr>
              <tr>
                <td>油速</td>
                <td>{{ itemsoB['oilVelocity'] }}</td>
                <td>
                  {{ itemsoB['oilVelocity'] }}
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </a-modal>
    <!-- 调机派工弹窗 -->
    <a-modal
      v-model:visible="visibleSH"
      title="调机派工"
      :draggable="true"
      width="1200px"
      style="z-index: 999"
    >
      <a-form size="mini" :model="pageData" layout="inline" label-align="right" ref="formRef">
        <a-form-item label="调机单号" :style="{ width: '260px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['adjustmentCode']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item label="机台号" :style="{ width: '260px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['machineCode']" disabled class="bacClass" />
        </a-form-item>
        <a-form-item label="调机开始时间" :style="{ width: '270px' }" label-col-flex="90px">
          <a-date-picker
            popup-container="html"
            v-model="pageData.adjustment['startTime']"
            disabled
            format="YYYY-MM-DD HH:mm:ss"
            :class="{ timeClass: insertType != 1 }"
            show-time
            class="bacClass"
          />
        </a-form-item>

        <a-form-item label="调机结束时间" :style="{ width: '270px' }" label-col-flex="90px">
          <a-date-picker
            popup-container="html"
            v-model="pageData.adjustment['endTime']"
            disabled
            format="YYYY-MM-DD HH:mm:ss"
            :class="{ timeClass: insertType != 1 }"
            show-time
            class="bacClass"
          />
        </a-form-item>

        <a-form-item label="是否抽针" :style="{ width: '260px' }" label-col-flex="90px">
          <a-select
            popup-container="html"
            class="bacClass"
            v-model="pageData.adjustment['drawnNeedleState']"
            :allow-clear="true"
            disabled
          >
            <a-option :value="0">是</a-option>
            <a-option :value="1">否</a-option>
          </a-select>
        </a-form-item>

        <a-form-item label="织布单号" :style="{ width: '260px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['planOrderCode']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item label="生产单号" :style="{ width: '270px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['weaveCode']" class="bacClass" disabled />
        </a-form-item>

        <a-form-item label="楼层" :style="{ width: '270px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['storey']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item label="取样员" :style="{ width: '260px' }" label-col-flex="90px">
          <a-input
            v-model="pageData.adjustment['sampleStaff']"
            readonly
            @click="cxTable(0)"
            placeholder="点击选员工"
            class="bacClass"
            disabled
          />
        </a-form-item>

        <a-form-item label="客户名称" :style="{ width: '260px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['customName']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item label="坯布编号" :style="{ width: '270px' }" label-col-flex="90px">
          <a-input v-model="pageData.adjustment['greyCode']" disabled class="bacClass" />
        </a-form-item>

        <a-form-item label="坯布名称" :style="{ width: '270px' }" label-col-flex="90px">
          <a-input
            v-model="pageData.adjustment['grayName']"
            disabled
            :title="pageData.adjustment['grayName']"
            class="bacClass"
          />
        </a-form-item>

        <a-form-item label="调机布重量" :style="{ width: '260px' }" label-col-flex="90px">
          <a-input-number
            v-model="pageData.adjustment['adjustmentWeight']"
            class="input-demo bacClass"
            :min="0"
            disabled
            :max="1000000000000000"
          />
        </a-form-item>

        <a-form-item label="取样布重量" :style="{ width: '260px' }" label-col-flex="90px">
          <a-input-number
            v-model="pageData.adjustment['sampleWeight']"
            class="input-demo bacClass"
            :min="0"
            disabled
            :max="10000000000000000"
          />
        </a-form-item>

        <a-form-item label="是否开幅" :style="{ width: '270px' }" label-col-flex="90px">
          <a-select
            popup-container="html"
            class="bacClass"
            v-model="pageData.adjustment['widthState']"
            :allow-clear="true"
            disabled
          >
            <a-option :value="0">开幅</a-option>
            <a-option :value="1">不开幅</a-option>
          </a-select>
        </a-form-item>

        <a-form-item label="折扣比例(%)" :style="{ width: '270px' }" label-col-flex="90px">
          <a-input-number
            v-model="pageData.adjustment['adjustmentRatio']"
            class="input-demo bacClass"
            :min="0"
            :max="100"
          />
        </a-form-item>
        <a-form-item
          label="调机类型"
          :style="{ width: '260px' }"
          field="mechanicType"
          label-col-flex="90px"
        >
          <a-select
            popup-container="html"
            class="bacClass"
            v-model="pageData.adjustment['maintainType']"
            :allow-clear="true"
            @change="changeJx"
          >
            <a-option v-for="item in pageData.maintainTypeList" :value="item['machineTypeName']">
              {{ item['machineTypeName'] }}
            </a-option>
          </a-select>
        </a-form-item>

        <a-form-item
          label="最后调机类型"
          :style="{ width: '260px' }"
          field="lastTimeMaintainType"
          label-col-flex="90px"
        >
          <a-input
            v-model="pageData.adjustment['lastTimeMaintainType']"
            disabled
            class="bacClass"
          />
        </a-form-item>
        <a-form-item
          label="折扣单价"
          :style="{ width: '270px' }"
          field="discountPrice"
          label-col-flex="90px"
        >
          <a-input v-model="pageData.adjustment['discountPrice']" disabled class="bacClass" />
        </a-form-item>
      </a-form>
      <div style="width: 100%; border: 1px solid #ccc; height: 400px; overflow: auto">
        <div style="display: inline-block; width: 49%; vertical-align: top; padding: 5px">
          <table class="Table" style="margin: 0px auto">
            <thead>
              <tr>
                <td class="thClass">员工名称</td>
                <td class="thClass">分配</td>
                <td class="thClass">分配金额</td>
              </tr>
            </thead>
            <tbody>
              <tr v-for="(item, index) in pageData.checkRyList" :key="index">
                <td>{{ item['employeeName'] }}</td>
                <td>
                  <a-input-number
                    v-model="item['ratio']"
                    style="height: 30px; width: 80px"
                    class="input-demo bacClass"
                    :min="0"
                    :max="100"
                    @change="changeRatio(item)"
                  />
                </td>
                <td>{{ item['allocationAmount'].toFixed(2) }}</td>
              </tr>
            </tbody>
          </table>
        </div>
        <div style="display: inline-block; width: 50%">
          <table class="Table" style="margin: 0 auto; margin-top: 30px">
            <thead>
              <tr>
                <td class="thClass">调机项目</td>
                <td class="thClass">标准</td>
                <td class="thClass">调整</td>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>布架宽度</td>
                <td>{{ itemsoB1['clothRackWidth'] }}</td>
                <td>
                  <a-input class="bacClass" v-model="itemsoB['clothRackWidth']" />
                </td>
              </tr>
              <tr>
                <td>织针型号</td>
                <td>{{ itemsoB1['needleModel'] }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    class="bacClass"
                    :style="{ width: '210px' }"
                    :loading="needloading"
                    @search="needhandleSearch"
                    v-model="itemsoB['needleModel']"
                    :filter-option="false"
                    allow-search
                    allow-clear
                    @focus="needfocusSel"
                  >
                    <a-option v-for="item in pageData.nameList" :value="item.specName"
                      >{{ item.specName }}
                    </a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>织针1段</td>
                <td>{{ itemsoB1['needleOnePerod'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['needleOnePerod']"
                    class="bacClass"
                    allow-clear
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>织针2段</td>
                <td>{{ itemsoB1['needleTwoPerod'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['needleTwoPerod']"
                    class="bacClass"
                    allow-clear
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>织针3段</td>
                <td>{{ itemsoB1['needleThreePerod'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['needleThreePerod']"
                    class="bacClass"
                    allow-clear
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>织针4段</td>
                <td>{{ itemsoB1['needleFourPerod'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['needleFourPerod']"
                    class="bacClass"
                    allow-clear
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>争食</td>
                <td>{{ itemsoB1['dodge'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['dodge']"
                    class="bacClass"
                    allow-clear
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>分食</td>
                <td>{{ itemsoB1['broken'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['broken']"
                    class="bacClass"
                    allow-clear
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>不争不分</td>
                <td>{{ itemsoB1['allTrue'] == 1 ? '√' : '' }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['allTrue']"
                    class="bacClass"
                    allow-clear
                  >
                    <a-option :value="0"></a-option>
                    <a-option :value="1">√</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>布加张力A-D</td>
                <td>{{ itemsoB1['clothTensionAD'] }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['clothTensionAD']"
                    class="bacClass"
                    allow-clear
                  >
                    <a-option value="A">A</a-option>
                    <a-option value="B">B</a-option>
                    <a-option value="C">C</a-option>
                    <a-option value="D">D</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>布加张力1-16</td>
                <td>{{ itemsoB1['clothTensionOS'] }}</td>
                <td>
                  <a-select
                    popup-container="html"
                    v-model="itemsoB['clothTensionOS']"
                    class="bacClass"
                    allow-clear
                  >
                    <a-option :value="1">1</a-option>
                    <a-option :value="2">2</a-option>
                    <a-option :value="3">3</a-option>
                    <a-option :value="4">4</a-option>
                    <a-option :value="5">5</a-option>
                    <a-option :value="6">6</a-option>
                    <a-option :value="7">7</a-option>
                    <a-option :value="8">8</a-option>
                    <a-option :value="9">9</a-option>
                    <a-option :value="10">10</a-option>
                    <a-option :value="11">11</a-option>
                    <a-option :value="12">12</a-option>
                    <a-option :value="13">13</a-option>
                    <a-option :value="14">14</a-option>
                    <a-option :value="15">15</a-option>
                    <a-option :value="16">16</a-option>
                  </a-select>
                </td>
              </tr>
              <tr>
                <td>底座垫片</td>
                <td>{{ itemsoB1['baseGasket'] }}</td>
                <td>
                  <a-input class="bacClass" v-model="itemsoB['baseGasket']" />
                </td>
              </tr>
              <tr>
                <td>送纱盘-中盘</td>
                <td>{{ itemsoB1['sandTrayMiddlePlate'] }}</td>
                <td>
                  <a-input-number class="bacClass" v-model="itemsoB['sandTrayMiddlePlate']" />
                </td>
              </tr>
              <tr>
                <td>送纱盘-面盘</td>
                <td>{{ itemsoB1['sandTableSurfacePlate'] }}</td>
                <td>
                  <a-input-number class="bacClass" v-model="itemsoB['sandTableSurfacePlate']" />
                </td>
              </tr>
              <tr>
                <td>送沙盘-底盘</td>
                <td>{{ itemsoB1['sandDownSurfacePlate'] }}</td>
                <td>
                  <a-input-number class="bacClass" v-model="itemsoB['sandDownSurfacePlate']" />
                </td>
              </tr>
              <tr>
                <td>齿轮</td>
                <td>{{ itemsoB1['gear'] }}</td>
                <td>
                  <a-input class="bacClass" v-model="itemsoB['gear']" />
                </td>
              </tr>
              <tr>
                <td>机速</td>
                <td>{{ itemsoB1['engineSpeed'] }}</td>
                <td>
                  <a-input-number
                    v-model="itemsoB['engineSpeed']"
                    placeholder=""
                    class="bacClass"
                    :min="0"
                    :max="1000000000000"
                    :precision="2"
                  />
                </td>
              </tr>
              <tr>
                <td>油速</td>
                <td>{{ itemsoB1['oilVelocity'] }}</td>
                <td>
                  <a-input-number
                    v-model="itemsoB['oilVelocity']"
                    placeholder=""
                    class="bacClass"
                    :min="0"
                    :max="1000000000000"
                    :precision="2"
                  />
                </td>
              </tr>
              <tr>
                <td>实开路数</td>
                <td>{{ itemsoB1['actualOpenWay'] }}</td>
                <td>
                  <a-input v-model="itemsoB['actualOpenWay']" placeholder="" class="bacClass" />
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <template #footer>
        <a-button type="primary" @click="handleBeforeOkSH" size="mini">保存</a-button>
        <a-button size="mini" @click="handleCancelSH">关闭</a-button>
      </template>
    </a-modal>
    <a-modal
      v-model:visible="editMaintainTypeVisible"
      @ok="handleEditMaintainTypeOk"
      @cancel="handleEditMaintainTypeCancel"
      width="600px"
    >
      <template #title> 修改调机类型 </template>
      <div style="display: flex; flex-wrap: wrap">
        <a-space size="large">
          <a-radio-group v-model="editMaintainType">
            <a-radio
              v-for="item in maintainTypeList1"
              :value="item.machineTypeName"
              style="width: 80px"
            >
              {{ item.machineTypeName }}
            </a-radio>
          </a-radio-group>
        </a-space>
      </div>
    </a-modal>
    <a-modal
      v-model:visible="checkTableVisible"
      width="600px"
      @ok="handleCheckTableOk"
      @cancel="handleCheckTableCancel"
      @close="handleCheckTableCancel"
    >
      <template #title> 点检表 </template>
      <div style="display: flex; flex-wrap: wrap; width: 100%; height: 100%">
        <a-checkbox-group
          style="display: flex; flex-wrap: wrap; width: 100%; height: 100%"
          v-model="checkBoxIds"
        >
          <a-checkbox
            v-for="item in checkBoxList"
            key="item.projectCode"
            style="flex-basis: calc(33.33% - 10px); margin-right: 10px"
            :value="item.projectCode"
            >{{ item.projectCode + '-' + item.projectName }}
          </a-checkbox>
        </a-checkbox-group>
      </div>
    </a-modal>
    <a-modal
      v-model:visible="checkTableDetailVisible"
      @cancel="handleCheckTableDetailCancel"
      width="600px"
      @close="handleCheckTableDetailCancel"
    >
      <template #title> 点检表 </template>
      <div style="display: flex; flex-wrap: wrap; width: 100%; height: 100%">
        <a-checkbox-group
          style="display: flex; flex-wrap: wrap; width: 100%; height: 100%"
          v-model="checkBoxIds"
        >
          <a-checkbox
            disabled
            v-for="item in checkBoxList"
            key="item.projectCode"
            style="flex-basis: calc(33.33% - 10px); margin-right: 10px; color: black"
            class="custom-disabled-checkbox"
            :value="item.projectCode"
            >{{ item.projectCode + '-' + item.projectName }}
          </a-checkbox>
        </a-checkbox-group>
      </div>
      <template #footer>
        <el-button @click="handleCheckTableDetailCancel">关闭</el-button>
      </template>
    </a-modal>
    <!--    完结弹窗-->
    <a-modal v-model:visible="finishModalVisible" width="400px">
      <template #title> 完结 </template>
      <div style="display: flex; justify-content: center; align-items: center"
        >确认完结选中的数据？</div
      >
      <template #footer>
        <div style="display: flex; justify-content: space-around; align-items: center">
          <a-button @click="handleFinishCancel">取消</a-button>
          <a-button type="primary" @click="handleFinishOk('1')">洗机</a-button>
          <a-button status="danger" @click="handleFinishOk('0')">非洗机</a-button>
        </div>
      </template>
    </a-modal>
  </pageTabelLayout>
</template>

<script lang="ts">
  import { get, post } from '@/api/http'
  import {
    usePagination,
    useRowKey,
    useRowSelection,
    useTable,
    useTableColumn,
  } from '@/hooks/table'
  import { getCurrentInstance, nextTick, onMounted, reactive, ref, watch } from 'vue'
  import Toolbar from '@/components/Toolbar.vue'
  import { Form, Message, Modal } from '@arco-design/web-vue'
  import { FormInstance } from '@arco-design/web-vue/es/form'
  import printJS from 'print-js'
  import usePermission from '@/store/modules/permission'
  import PageTabelLayout from '@/components/pageTabelLayout.vue'
  // 引入

  import { localeText } from '@/api/aggridZw'
  import { pagingList } from '@/api/paging'
  import CorporateSectorCascader from '@/components/corporateSectorCascader/inde.vue'
  import { saveOrUpdateGridState as saveOrUpdateGridState01 } from '@/hooks/useGridState'
  import { saveOrUpdateGridState as saveOrUpdateGridState02 } from '@/hooks/useGridState'
  import { saveOrUpdateGridState as saveOrUpdateGridState04 } from '@/hooks/useGridState'
  import { saveOrUpdateGridState as saveOrUpdateGridState05 } from '@/hooks/useGridState'
  import useAgGridFilterSelector from '@/utils/aggridFilterAllSelect'
  import { ElMessage } from 'element-plus'
  import { baseURL } from '@/api/axios.config'
  import _ from 'lodash'
  import dayjs from 'dayjs'
  //全局变量 用于保存点击完结当前行id
  let tempFinishId: any = ''

  interface ClothInfo {
    id: any
    adjustmentCode: string | undefined
    machineCode: string | undefined
    weaveCode: string | undefined
    planOrderCode: string | undefined
    greyCode: string | undefined
    grayName: string | undefined
    customName: string | undefined
    storey: string | undefined
    employeeId: string | undefined
    employeeName: string | undefined
    lastTimeMaintainDate: string | undefined
    schedulStartDate: string | undefined
    schedulEndDate: string | undefined
    dutymachineStartDate: string | undefined
    dutymachineEndDate: string | undefined
    adjustmentState: any | undefined
    dispatchState: number | undefined
    monitorState: number | undefined
    monitor: string | undefined
    obsoleteState: number | undefined
    deleteState: number | undefined
    remark: string | undefined
    createName: string | undefined
    createTime: string | undefined
    updateName: string | undefined
    updateTime: string | undefined
  }

  export default {
    name: 'Spedizione',
    setup: function () {
      const table1Ref = ref<any>(null)
      const drawerTableColumns = [
        {
          field: '',
          headerCheckboxSelection: true,
          checkboxSelection: true,
          width: 50,
          showDisabledCheckboxes: false,
          pinned: 'left',
        },
        {
          headerName: '保养项目名称',
          field: 'upkeepName',
          width: 250,
        },
      ]
      const pictures = ref<any>([])
      let configTable1 = {
        url: '', //接口路径
        queryData: {},
        paginationShow: false, //分页是否显示
        invokeiIterface: false, //是否调用接
        rowMultiSelectWithClick: true, //点击行是否多选
        column: drawerTableColumns,
        fileName: '',
      }

      const { proxy } = getCurrentInstance()
      const aggridFs4 = useAgGridFilterSelector()
      const aggridFs2 = useAgGridFilterSelector()
      const aggridFs = useAgGridFilterSelector()
      const aggridFs5 = useAgGridFilterSelector()
      const tabValue = ref<any>(proxy.$route.query.name)
      const pageData1 = reactive<any>({
        tableIndex: tabValue || '1',
      })
      // let cascaderRef = ref('')
      let configCascader = ref<{}>({
        corporateWidth: '400px', //公司宽度
        sectorWidth: '400px', //部门宽度
        corporateRquired: false, //公司是否必填
        sectorRquired: false, //部门是否必填
        size: 'small', //选择框大小'mini' | 'small' | 'medium' | 'large'
        corporateName: '公司', //公司label
        sectorName: '部门', //部门label
      })
      const changeCascader = (data: any) => {
        pageData.ygName = ''
        pageData.ygNameList = []
        const { corporateId, sectorId } = data
        pageData.firmId = corporateId
        pageData.applyBranchId = sectorId
      }
      const headerShow = ref<boolean>(true)
      const total = ref(0)
      const page = ref(1)
      const size = ref(10)

      function change1(val: any) {
        if (tableId.value == 1) {
          paginations1.pageSize = val
          doRefresh4()
        } else {
          pagination.pageSize = val
          doRefresh()
        }
      }
      function PageSize(val: any) {
        if (tableId.value == 1) {
          paginations1.page = val
          doRefresh4()
        } else {
          pagination.page = val
          doRefresh()
        }
      }

      //查询
      function doRefresh() {
        pageData.pageLoading = true

        let params = {
          page: pagination.page,
          size: pagination.pageSize,
          deleteState: 0,
          adjustmentState: pageData.adjustmentState,
          adjustmentCode: pageData.adjustmentCode,
          greyCode: pageData.greyCode,
          grayName: pageData.grayName,
          planOrderCode: pageData.planOrderCode,
          weaveCode: pageData.weaveCode,
          storey: pageData.storey,
          empVerifyTimeStart: pageData.empVerifyTimeStart,
          empVerifyTimeEnd: pageData.empVerifyTimeEnd,
          dutyMonitorState: 1,
          accomplishState: pageData.accomplishState,
          machineCode: pageData.machineCode,
          empEndTimeStart: pageData.empEndTimeStart,
          empEndTimeEnd: pageData.empEndTimeEnd,
          empFeedBackTimeStart: pageData.empFeedBackTimeStart,
          empFeedBackTimeEnd: pageData.empFeedBackTimeEnd,
        }
        if (tableId.value == 2) {
          switch (pageData.tjrwCode) {
            case '已查布头':
              params['inspectionState'] = '2'
              params['adjustmentState'] = '0,1,2'
              break
            case '已派工':
              params['adjustmentState'] = '1'
              params['inspectionState'] = '0,1'
              break
            case '未派工':
              params['adjustmentState'] = '0'
              params['inspectionState'] = '0,1'
              break
            case '调机中':
              params['adjustmentState'] = '2'
              params['inspectionState'] = '0,1'
              break
            case '已反馈':
              params['adjustmentState'] = '3'
              params['inspectionState'] = '0,1'
              break
            case '已交机':
              params['adjustmentState'] = '4'
              break
            default:
              break
          }
        }

        post({
          url: 'planSingle/adjustment/getPage',
          data: params,
        })
          .then(({ data, code, message }: any) => {
            if (code === 200) {
              table.handleSuccess(data.list)
              pagination.setTotalSize(data.total)
              pageData.dataList = data.list
              aggridFs4.resetAgFs()
              if (tableId.value == 2) {
                gridOption.value.setRowData(data.list)
                aggridFs.resetAgFs()
              } else if (tableId.value == 3) {
                gridOption2.value.setRowData(data.list)
                aggridFs2.resetAgFs()
              } else if (tableId.value == 4) {
                gridOption5.value.setRowData(data.list)
                aggridFs5.resetAgFs()
              }
            } else {
              Message.error({
                content: message,
                duration: 5000,
              })
            }
          })
          .catch(console.log)
          .finally(() => {
            pageData.pageLoading = false
          })
      }

      //待处理
      function doRefresh4() {
        pageData.pageLoading = true
        post({
          url: '/planSingle/adjustment/getPage',
          data: {
            page: paginations1.page,
            size: paginations1.pageSize,
            deleteState: 0,
            adjustmentCode: pageData.adjustmentCode,
            greyCode: pageData.greyCode,
            grayName: pageData.grayName,
            planOrderCode: pageData.planOrderCode,
            weaveCode: pageData.weaveCode,
            storey: pageData.storey,
            dateStart: pageData.dateStart,
            dateEnd: pageData.dateEnd,
            dutyMonitorState: 0,
            machineCode: pageData.machineCode,
          },
        })
          .then(({ data, code, message }: any) => {
            if (code === 200) {
              paginations1.setTotalSize(data.total)
              table.handleSuccess(data.list)
              console.log(gridOption4.value)
              gridOption4.value.setRowData(data.list)
            } else {
              Message.error({
                content: message,
                duration: 5000,
              })
            }
          })
          .catch(console.log)
          .finally(() => {
            pageData.pageLoading = false
          })
      }

      const { selectedRowKeys, onSelectionChange } = useRowSelection()
      const selectedRowKeysChecked = useRowSelection()
      const pagination = usePagination(doRefresh)
      const paginations1 = usePagination(doRefresh4)
      const table = useTable()
      const rowKey = useRowKey('id')
      const tableColumns = useTableColumn([
        {
          title: '公司',
          key: 'firm',
          dataIndex: 'firm',
          width: 150,
        },
        {
          title: '调机单号',
          key: 'adjustmentCode',
          dataIndex: 'adjustmentCode',
          width: 150,
        },
        {
          title: '机台号',
          key: 'machineCode',
          dataIndex: 'machineCode',
          width: 150,
        },
        {
          title: '生产单号',
          key: 'weaveCode',
          dataIndex: 'weaveCode',
          width: 150,
        },
        {
          title: '织布单号',
          key: 'planOrderCode',
          dataIndex: 'planOrderCode',
          width: 150,
        },
        {
          title: '坯布编号',
          key: 'greyCode',
          dataIndex: 'greyCode',
          width: 150,
        },

        {
          title: '坯布名称',
          key: 'grayName',
          dataIndex: 'grayName',
          width: 150,
        },

        {
          title: '客户名称',
          key: 'customName',
          dataIndex: 'customName',
          width: 150,
        },
        {
          title: '楼层',
          key: 'storey',
          dataIndex: 'storey',
          width: 150,
        },
        {
          title: '备注',
          key: 'remark',
          dataIndex: 'remark',
          width: 150,
        },
        {
          title: '调机确认时间',
          key: 'empVerifyTime',
          dataIndex: 'empVerifyTime',
          width: 200,
        },
        {
          title: '暂停状态',
          key: 'suspendState',
          dataIndex: 'suspendState',
          slotName: 'suspendState',
          // fixed: 'right',
          width: 100,
        },
        {
          title: '暂停时间',
          key: 'suspendTime',
          dataIndex: 'suspendTime',
          width: 100,
        },
        {
          title: '暂停人',
          key: 'suspendName',
          dataIndex: 'suspendName',
          width: 100,
        },
        {
          title: '调机类型',
          key: 'maintainType',
          dataIndex: 'maintainType',
          slotName: 'maintainType',
          width: 200,
          // fixed: 'right',
        },
        {
          title: '工艺复核',
          key: 'craftState',
          dataIndex: 'craftState',
          slotName: 'craftState',
          width: 200,
          // fixed: 'right',
        },
        {
          title: '状态',
          key: 'adjustmentState',
          dataIndex: 'adjustmentState',
          slotName: 'adjustmentState',
          width: 150,
          // fixed: 'right',
        },

        {
          title: '操作',
          key: 'id',
          dataIndex: 'id',
          slotName: 'act',
          width: 150,
          fixed: 'right',
        },
      ])
      const tableColumnsChecked = useTableColumn([
        {
          title: '公司',
          key: 'firm',
          dataIndex: 'firm',
          width: 150,
        },
        {
          title: '调机单号',
          key: 'adjustmentCode',
          dataIndex: 'adjustmentCode',
          width: 150,
        },
        {
          title: '机台号',
          key: 'machineCode',
          dataIndex: 'machineCode',
          width: 150,
        },

        {
          title: '生产单号',
          key: 'weaveCode',
          dataIndex: 'weaveCode',
          width: 150,
        },

        {
          title: '织布单号',
          key: 'planOrderCode',
          dataIndex: 'planOrderCode',
          width: 150,
        },

        {
          title: '坯布编号',
          key: 'greyCode',
          dataIndex: 'greyCode',
          width: 150,
        },

        {
          title: '坯布名称',
          key: 'grayName',
          dataIndex: 'grayName',
          width: 150,
        },

        {
          title: '班长确认',
          key: 'monitor',
          dataIndex: 'monitor',
          width: 150,
        },
        {
          title: '是否抽针',
          key: 'drawnNeedleState',
          dataIndex: 'drawnNeedleState',
          slotName: 'drawnNeedleState',
          width: 150,
        },
        {
          title: '是否开幅',
          key: 'widthState',
          dataIndex: 'widthState',
          slotName: 'widthState',
          width: 150,
        },
        {
          title: '客户名称',
          key: 'customName',
          dataIndex: 'customName',
          width: 150,
        },
        {
          title: '楼层',
          key: 'storey',
          dataIndex: 'storey',
          width: 150,
        },
        {
          title: '备注',
          key: 'remark',
          dataIndex: 'remark',
          width: 150,
        },
        {
          title: '完成状态',
          key: 'accomplishState',
          dataIndex: 'accomplishState',
          slotName: 'accomplishState',
          width: 150,
        },
        {
          title: '最近一次机修调机单号',
          key: 'lastTimeMaintainCode',
          dataIndex: 'lastTimeMaintainCode',
          width: 150,
        },
        {
          title: '最近一次修机类型',
          key: 'lastTimeMaintainType',
          dataIndex: 'lastTimeMaintainType',
          width: 150,
        },
        {
          title: '调机反馈时间',
          key: 'empFeedBackTime',
          dataIndex: 'empFeedBackTime',
          width: 150,
        },
        {
          title: '交机时间',
          key: 'empEndTime',
          dataIndex: 'empEndTime',
          width: 150,
        },
        {
          title: '工艺复核',
          key: 'craftState',
          dataIndex: 'craftState',
          slotName: 'craftState',
          width: 200,
          // fixed: 'right',
        },
        {
          title: '调机类型',
          key: 'maintainType',
          dataIndex: 'maintainType',
          slotName: 'maintainType',
          width: 200,
          // fixed: 'right',
        },
        {
          title: '操作',
          key: 'id',
          dataIndex: 'id',
          slotName: 'action',
          width: 150,
          fixed: 'right',
        },
      ])
      let adjustment = reactive({
        id: null,
        adjustmentCode: '',
        machineCode: '',
        startTime: '',
        endTime: '',
        adjustmentRatio: 100,
        sampleStaffId: 0,
        weaveCode: '',
        planOrderCode: '',
        greyCode: '',
        grayName: '',
        monitor: '',
        monitorState: 0,
        drawnNeedleState: '',
        widthState: '',
        customName: '',
        sampleWeight: 0,
        sampleStaff: '',
        adjustmentWeight: 0,
        storey: '',
        accomplishState: 0,
        lastTimeMaintainCode: '',
        lastTimeMaintainType: '',
        lastTimeMaintainDate: '',
        adjustmentState: 0,
        obsoleteState: 0,
        deleteState: 0,
        remark: '',
        createName: '',
        createTime: '',
        updateName: '',
        updateTime: '',
        discountPrice: 0,
        machineId: '',
      })
      const pageData = reactive<{
        showAdd: boolean
        sideTitle: string
        adjustmentCode: any
        greyCode: any
        grayName: any
        planOrderCode: any
        weaveCode: any
        storey: any
        lastTimeMaintainDate: any[]
        dutymachineDate1: any[]
        pageLoading: boolean
        rHeight: any
        adjustmentState: any | undefined
        checkHeadList: any[]
        checkBodyList: any[]
        bodyValueList: any[]
        dataList: any[]
        machineCodeOb: {}
        getList: any[]
        dropDownList: any[]
        tcDutymachineCode: any
        tcStorey: any
        tcDutymachineCodeList: any[]
        tcStoreyList: any[]
        ygType: any
        ygName: any
        ygTypeList: any[]
        ygNameList: any[]
        firmList: any[]
        firmId: any
        isShow: boolean
        isShow1: boolean
        filterList: any[]
        editYgTime: any[]
        employeeId: any
        employeeName: string | undefined
        checkRyList: any[]
        adjustment: any
        lastTimeMaintainTypeList: any[]
        NowDate: any
        dateEnd: any
        dateStart: any
        applyBranchId: string
        maintainTypeList: any[]
        machineList: any[]
        btnList: any[]
        nameList: any[]
        isXq: boolean
        accomplishState: any
        isXq1: boolean
        empVerifyTimeStart: any
        empVerifyTimeEnd: any
        empEndTimeStart: any
        empEndTimeEnd: any
        empFeedBackTimeStart: any
        empFeedBackTimeEnd: any
        weaveCodeList: any
        tjrwCode: any
        departmentId: any
      }>({
        isXq1: false,
        accomplishState: 0,
        tjrwCode: '',
        showAdd: false,
        sideTitle: '新增调机派工',
        adjustmentCode: '',
        greyCode: '',
        grayName: '',
        planOrderCode: '',
        weaveCode: '',
        storey: '',
        lastTimeMaintainDate: [],
        dutymachineDate1: [],
        pageLoading: false,
        rHeight: '',
        adjustmentState: 0,
        checkHeadList: [],
        checkBodyList: [],
        bodyValueList: [],
        dataList: [],
        machineCodeOb: {},
        getList: [],
        dropDownList: [],
        tcDutymachineCode: '',
        tcStorey: '',
        tcDutymachineCodeList: [],
        tcStoreyList: [],
        ygType: '',
        ygName: '',
        ygTypeList: [],
        ygNameList: [],
        firmList: [],
        firmId: null,
        isShow: true,
        isShow1: true,
        filterList: [],
        editYgTime: [],
        employeeId: null,
        employeeName: '',
        checkRyList: [],
        adjustment: adjustment,
        lastTimeMaintainTypeList: [],
        NowDate: '',
        dateEnd: '',
        dateStart: '',
        applyBranchId: '',
        maintainTypeList: [],
        machineList: [],
        btnList: [],
        nameList: [],
        isXq: false,
        empVerifyTimeStart: '',
        empVerifyTimeEnd: '',
        empEndTimeStart: '',
        empEndTimeEnd: '',
        empFeedBackTimeStart: '',
        empFeedBackTimeEnd: '',
        weaveCodeList: [],
        departmentId: null,
      })
      const handleDrawerClose = () => {
        for (let key in pageData.adjustment) {
          pageData.adjustment[key] = ''
        }
        pageData.weaveCodeList = []
        isDispatchWorkDetail.value = false
        formRef1.value.resetFields()
        pageData.isXq1 = false
        console.log('close', pageData.adjustment)
      }
      // 表格准备事件
      const gridOption = ref()
      const colState = ref()
      const gridReady = (params: any) => {
        console.log('C3', params)
        gridOption.value = params.api
        colState.value = params.columnApi
      }
      // 表格准备事件
      const gridOption2 = ref()
      const colState2 = ref()
      const gridReady2 = (params: any) => {
        console.log('C2', params)
        gridOption2.value = params.api
        colState2.value = params.columnApi
      }
      // 表格准备事件
      const gridOption4 = ref()
      const colState4 = ref()
      const gridReady4 = (params: any) => {
        console.log('C', params)
        gridOption4.value = params.api
        colState4.value = params.columnApi
      }
      // 表格准备事件
      const gridOption5 = ref()
      const colState5 = ref()
      const gridReady5 = (params: any) => {
        console.log('C4', params)
        gridOption5.value = params.api
        colState5.value = params.columnApi
      }
      //下拉框得到焦点
      const focusSel = (val: any) => {
        selCxAll(val)
      }
      //下拉数据
      const options = ref<any>(pageData.dropDownList)
      const loading = ref(false)
      const handleSearch = (value: any, key: any) => {
        if (value) {
          const ob = { adjustmentCode: value }
          loading.value = true
          selCxAll(ob)
          options.value = pageData.dropDownList
          loading.value = false
        } else {
          options.value = []
        }
      }
      const handleSearch1 = (value: any) => {
        if (value) {
          const ob = { greyCode: value }
          loading.value = true
          selCxAll(ob)
          options.value = pageData.dropDownList
          loading.value = false
        } else {
          options.value = []
        }
      }
      const handleSearch2 = (value: any) => {
        if (value) {
          const ob = { grayName: value }
          loading.value = true
          selCxAll(ob)
          options.value = pageData.dropDownList
          loading.value = false
        } else {
          options.value = []
        }
      }
      const handleSearch3 = (value: any) => {
        if (value) {
          const ob = { planOrderCode: value }
          loading.value = true
          selCxAll(ob)
          options.value = pageData.dropDownList
          loading.value = false
        } else {
          options.value = []
        }
      }
      const handleSearch4 = (value: any) => {
        if (value) {
          const ob = { weaveCode: value }
          loading.value = true
          selCxAll(ob)
          options.value = pageData.dropDownList
          loading.value = false
        } else {
          options.value = []
        }
      }
      const handleSearch5 = (value: any) => {
        if (value) {
          const ob = { storey: value }
          loading.value = true
          selCxAll(ob)
          options.value = pageData.dropDownList
          loading.value = false
        } else {
          options.value = []
        }
      }

      //下拉框查询
      function selCxAll(val: any) {
        if (tableId.value == 2) {
          val['adjustmentState'] = '0,1'
        } else if (tableId.value == 3) {
          val['adjustmentState'] = '2,3'
        }
        post({
          url: 'planSingle/adjustment/getFieldValue',
          data: val,
        }).then(({ data, code }: any) => {
          if (code === 200) {
            // (data as string[]).splice(0, 0, "全部");
            pageData.dropDownList = data
          } else {
            Message.error({
              content: '查询失败！',
              duration: 5000,
            })
          }
        })
      }

      onMounted(() => {
        getUserToken()
        if (tableId.value === 1) {
          //调机待确定
          getTjdqrPermission()
        } else if (tableId.value === 2) {
          //调机任务
          getTjrwPermission()
        } else if (tableId.value === 3) {
          //交机待确认
          getJjdqrPermission()
        } else if (tableId.value === 4) {
          //调机审核
          getTjshPermission()
        }
        updateGridState01()
        updateGridState02()
        updateGridState04()
        updateGridState05()
        doRefresh4()
        pageData.rHeight = document.getElementById('CheckDispatching')?.clientHeight
        //表格的高
        if (pageData.rHeight !== undefined) {
          pageData.rHeight = pageData.rHeight - 210
        }
        window.addEventListener('resize', () => {
          pageData.rHeight = document.getElementById('CheckDispatching')?.clientHeight

          //表格的高
          if (pageData.rHeight !== undefined) {
            pageData.rHeight = pageData.rHeight - 210
          }
        })
        //已调机 未调机tab切换
        if (tableId.value == 2) {
          pageData.adjustmentState = '0,1'
          doRefresh()
        } else if (tableId.value == 3) {
          pageData.adjustmentState = '2,3'
          doRefresh()
        }
      })
      //查询
      const selectHandler = () => {
        if (tableId.value == 1) {
          paginations1.page = 1
          doRefresh4()
        } else {
          pagination.page = 1
          doRefresh()
        }
      }
      const addHandler = () => {
        for (var key in dataForm) {
          if (key === 'id') {
            dataForm[key] = null
          } else {
            dataForm[key] = ''
          }
        }
        pageData.showAdd = true
        pageData.sideTitle = '新增调机派工'
      }

      const dataForm = reactive<ClothInfo>({
        id: null,
        adjustmentCode: '',
        machineCode: '',
        weaveCode: '',
        planOrderCode: '',
        greyCode: '',
        grayName: '',
        customName: '',
        storey: '',
        employeeId: '',
        employeeName: '',
        lastTimeMaintainDate: '',
        schedulStartDate: '',
        schedulEndDate: '',
        dutymachineStartDate: '',
        dutymachineEndDate: '',
        adjustmentState: 0,
        dispatchState: 0,
        monitorState: 0,
        monitor: '',
        obsoleteState: 0,
        deleteState: 0,
        remark: '',
        createName: '',
        createTime: '',
        updateName: '',
        updateTime: '',
      })
      const formRef = ref<FormInstance>()
      const formRef1 = ref<any>(null)
      const sideOk = () => {
        // pageData.showAdd = false
        // formRef.value?.validate().then((err) => {
        //   if (!err) {

        //   }
        // })
        // if(pageData.editYgTime.length != 0){
        // }
        pageData.editYgTime.forEach(function (o) {
          if (
            o['adjustmentStartDate'] == null ||
            o['adjustmentStartDate'] == undefined ||
            o['adjustmentStartDate'] == ''
          ) {
            o['adjustmentStartDate'] = pageData.NowDate
          }
          if (
            o['adjustmentEndDate'] == null ||
            o['adjustmentEndDate'] == undefined ||
            o['adjustmentEndDate'] == ''
          ) {
            o['adjustmentEndDate'] = pageData.NowDate
          }
        })
        let dataOb = {}
        if (pageData.editYgTime.length > 0) {
          dataOb['adjustmentId'] = pageData.editYgTime[0]['adjustmentId']
          dataOb['userList'] = pageData.editYgTime
          dataOb['spotInfo'] = []
        }
        post({
          url: 'planSingle/adjustment/monitorConfirm',
          data: dataOb,
        }).then((res: any) => {
          if (res.code === 200) {
            formRef.value?.resetFields()

            pageData.showAdd = false

            Message.success({
              content: '班长确认成功',
              duration: 5000,
            })
            doRefresh()
          } else {
            Message.error({
              content: res.message,
              duration: 5000,
            })
          }
        })
      }

      const sideOks = (id: any) => {
        post({
          url: 'planSingle/adjustment/monitorConfirm',
          data: {
            adjustmentId: id,
            spotInfo: [],
          },
        }).then((res: any) => {
          if (res.code === 200) {
            formRef.value?.resetFields()
            Message.success({
              content: '班长确认成功',
              duration: 5000,
            })
            doRefresh()
          } else {
            Message.error({
              content: res.message,
              duration: 5000,
            })
          }
        })
      }

      //班长确认
      const editHandler = (record: ClothInfo) => {
        var day2 = new Date()
        pageData.NowDate = day2.getFullYear() + '-' + (day2.getMonth() + 1) + '-' + day2.getDate()

        dataForm.id = record.id
        getUserList(record.id, 2)
      }
      let originData: any
      const compareObj = (obj1: {}, obj2: {}) => {
        //不知道为什么多了一个这个key  所以删掉
        const keys1 = Object.keys(obj1).filter((item) => item !== 'discountPrice')
        const keys2 = Object.keys(obj2)
        let count = 0
        if (keys1.length !== keys2.length) {
          return false
        }
        for (let i = 0; i < keys1.length; i++) {
          if (keys1[i] !== 'maintainType') {
            if (obj1[keys1[i]] == obj2[keys1[i]]) {
              count++
            }
          }
        }
        if (count == keys1.length - 1) {
          return true
        }
        return false
      }
      //拿到数据
      function getUserList(id: any, num: any) {
        post({
          url: 'planSingle/adjustment/getDispatchByAdjustmentId',
          data: { adjustmentId: id },
        }).then(({ code, data, message }: any) => {
          if (code === 200) {
            pageData.adjustment = data['adjustment']
            if (num == 1) {
              originData = _.cloneDeep(pageData.adjustment)
            }
            if (num == 2) {
              //班长确认
              if (data['userList'].length == 0) {
                // Message.warning({
                //   content: '暂无数据',
                //   duration: 5000,
                // })
                Modal.confirm({
                  title: '系统提示',
                  content: '确认交机确认？',
                  onOk() {
                    sideOks(id)
                  },
                })
              } else {
                pageData.editYgTime = data['userList']
                pageData.sideTitle = '修改调机机派工'
                // pageData.showAdd = true
                Modal.confirm({
                  title: '系统提示',
                  content: '确认交机确认？',
                  onOk() {
                    sideOk()
                  },
                })
              }
            } else {
              //派工 员工
              if (data['userList'].length > 0) {
                pageData.checkRyList = data['userList']
                pageData.checkRyList.forEach(function (o: any) {
                  o['allocationAmount'] = 0
                })
              }
              //调机项目
              if (data['adjustmentStandard'] != null && data['adjustmentStandard'] != '') {
                if (Object.keys(data['adjustmentStandard']).length > 0) {
                  for (let key in data['adjustmentStandard']) {
                    itemsoB[key] = data['adjustmentStandard'][key]
                  }
                }
              }
            }
            //图片
            if (data['adjustmentStandardImage']?.length > 0) {
              pictures.value = data['adjustmentStandardImage']
            } else {
              pictures.value = []
            }
            cxDiscountPrice()
          } else {
            Message.error({
              content: message,
              duration: 5000,
            })
          }
        })
      }

      //点击单元格删除本行 且删除此数据
      const delRow = (idYg: any) => {
        pageData.checkRyList = pageData.checkRyList.filter(function (o) {
          return o['id'] !== idYg
        })
      }

      function reSetAdjustment() {
        pageData.adjustment.id = null
        pageData.adjustment.adjustmentCode = ''
        pageData.adjustment.machineCode = ''
        pageData.adjustment.startTime = ''
        pageData.adjustment.endTime = ''
        pageData.adjustment.adjustmentRatio = 100
        pageData.adjustment.sampleStaffId = 0
        pageData.adjustment.weaveCode = ''
        pageData.adjustment.planOrderCode = ''
        pageData.adjustment.greyCode = ''
        pageData.adjustment.grayName = ''
        pageData.adjustment.monitor = ''
        pageData.adjustment.monitorState = 0
        pageData.adjustment.drawnNeedleState = ''
        pageData.adjustment.widthState = ''
        pageData.adjustment.customName = ''
        pageData.adjustment.sampleWeight = 0
        pageData.adjustment.sampleStaff = ''
        pageData.adjustment.adjustmentWeight = 0
        pageData.adjustment.storey = ''
        pageData.adjustment.accomplishState = 0
        pageData.adjustment.lastTimeMaintainCode = ''
        pageData.adjustment.lastTimeMaintainType = ''
        pageData.adjustment.lastTimeMaintainDate = ''
        pageData.adjustment.adjustmentState = 0
        pageData.adjustment.obsoleteState = 0
        pageData.adjustment.deleteState = 0
        pageData.adjustment.remark = ''
        pageData.adjustment.createName = ''
        pageData.adjustment.createTime = ''
        pageData.adjustment.updateName = ''
        pageData.adjustment.updateTime = ''
        pageData.adjustment.discountPrice = 0
        pageData.adjustment.machineId = ''
      }

      let itemsoB = reactive({
        id: '',
        greyCloth: '',
        nameCloth: '',
        machineType: '',
        machineID: '',
        cylinderCoding: '',
        clothRackWidth: '',
        needleModel: '',
        needleOnePerod: 0,
        needleTwoPerod: 0,
        needleThreePerod: 0,
        needleFourPerod: 0,
        dodge: 0,
        broken: 0,
        allTrue: 0,
        clothTensionAD: '',
        clothTensionOS: 1,
        baseGasket: '',
        sandTrayMiddlePlate: 0,
        sandTableSurfacePlate: 0,
        gear: '',
        needleGrade: '',
        engineSpeed: 0,
        oilVelocity: 0,
      })
      let itemsoB1 = reactive({
        id: '',
        greyCloth: '',
        nameCloth: '',
        machineType: '',
        machineID: '',
        cylinderCoding: '',
        clothRackWidth: '',
        needleModel: '',
        needleOnePerod: 0,
        needleTwoPerod: 0,
        needleThreePerod: 0,
        needleFourPerod: 0,
        dodge: 0,
        broken: 0,
        allTrue: 0,
        clothTensionAD: '',
        clothTensionOS: 1,
        baseGasket: '',
        sandTrayMiddlePlate: 0,
        sandTableSurfacePlate: 0,
        gear: '',
        needleGrade: '',
        engineSpeed: 0,
        oilVelocity: 0,
      })

      function reSetItemsoB() {
        itemsoB.id = ''
        itemsoB.greyCloth = ''
        itemsoB.nameCloth = ''
        itemsoB.machineType = ''
        itemsoB.machineID = ''
        itemsoB.cylinderCoding = ''
        itemsoB.clothRackWidth = ''
        itemsoB.needleModel = ''
        itemsoB.needleOnePerod = 0
        itemsoB.needleTwoPerod = 0
        itemsoB.needleThreePerod = 0
        itemsoB.needleFourPerod = 0
        itemsoB.dodge = 0
        itemsoB.broken = 0
        itemsoB.allTrue = 0
        itemsoB.clothTensionAD = ''
        itemsoB.clothTensionOS = 0
        itemsoB.baseGasket = ''
        itemsoB.sandTrayMiddlePlate = 0
        itemsoB.sandTableSurfacePlate = 0
        itemsoB.gear = ''
        itemsoB.needleGrade = ''
        itemsoB.engineSpeed = 0
        itemsoB.oilVelocity = 0
      }

      //调机派工弹窗
      const visible = ref(false)
      const visibleSH = ref(false)
      const booleanSH = ref(false)
      let isSelectedUpkeepList: any = []
      const getSelectedMaintenanceProject = async (id: any) => {
        await post({
          url: 'planSingle/adjustmentUpkeep/getUpKeepListByAdjustmentId',
          data: {
            adjustmentId: id,
          },
        }).then((res: any) => {
          if (res.code == 200) {
            res.data.forEach((item: any) => {
              if (item['upkeepState'] == 1) {
                isSelectedUpkeepList.push(item['upkeepName'])
              }
            })
          } else {
            Message.error({
              content: res.message,
              duration: 5000,
            })
          }
        })
      }
      const handleClick = async (type: any) => {
        isSelectedUpkeepList = []
        insertType.value = 1
        pageData.checkRyList = []
        pageData.checkBodyList = []
        pageData.checkHeadList = []
        pageData.getList = []
        pageData.bodyValueList = []
        pageData.isXq = false
        if (type == 1) {
          //派工
          if (gridOption.value.getSelectedRows().length != 1) {
            Message.warning({
              content: '请勾选一行数据',
              duration: 5000,
            })
            return
          }
          if (gridOption.value.getSelectedRows()[0]['maintainType'] == '转单') {
            Message.warning({
              content: '转单状态下不允许派工！',
              duration: 5000,
            })
            return
          }
          if (gridOption.value.getSelectedRows()[0]['adjustmentState'] != 0) {
            Message.warning({
              content: '请勾选未派工数据',
              duration: 5000,
            })
            return
          }
          if (gridOption.value.getSelectedRows()[0]['suspendState'] != 0) {
            Message.warning({
              content: '生产单已暂停，无法派工！',
              duration: 5000,
            })
            return
          }
          pageData.isXq1 = true
          //筛选出勾选行的数据
          pageData.filterList = pageData.dataList.filter(function (o) {
            return o['id'] == gridOption.value.getSelectedRows()[0]['id']
          })
          for (const key in pageData.filterList[0]) {
            if (key === 'adjustmentRatio') {
              pageData.filterList[0][key] = parseFloat(pageData.filterList[0][key])
            }
            pageData.adjustment[key] = pageData.filterList[0][key]
          }
          let params: any = pageData.adjustment
          params['adjustmentState'] = 1
          console.log('params', params)
          post({
            url: 'planSingle/adjustment/dispatchVerify',
            data: {
              adjustment: params,
            },
          }).then(({ code, data, message }: any) => {
            if (code != 200) {
              Message.error({
                content: message,
                duration: 5000,
              })
              return
            } else {
              getlastTimeMaintainTypeList()

              //将调机项目 数据渲染上去 左边
              post({
                url: 'planSingle/machineStandard/getOntByGrey',
                data: {
                  greyCloth: pageData.filterList[0]['greyCode'],
                  nameCloth: pageData.filterList[0]['greyName'],
                },
              }).then(({ code, data, message }: any) => {
                if (code === 200) {
                  for (let key in data) {
                    itemsoB1[key] = data[key]
                  }
                  if (booleanSH.value == true) {
                    visibleSH.value = true
                  } else {
                    visible.value = true
                  }
                } else {
                  Message.error({
                    content: message,
                    duration: 5000,
                  })
                }
              })

              getUserList(pageData.filterList[0]['id'], 1)
            }
          })
        } else {
          isDispatchWorkDetail.value = true
          pageData.filterList = [type]
          if (type['xq']) {
            pageData.isXq = true
          }

          //将调机项目 数据渲染上去 左边
          post({
            url: 'planSingle/machineStandard/getOntByGrey',
            data: {
              greyCloth: pageData.filterList[0]['greyCode'],
              nameCloth: pageData.filterList[0]['greyName'],
            },
          }).then(({ code, data, message }: any) => {
            if (code === 200) {
              for (let key in data) {
                itemsoB1[key] = data[key]
              }
              if (booleanSH.value == true) {
                getlastTimeMaintainTypeList()
                visibleSH.value = true
              } else {
                filterMaintainTypeList()
                visible.value = true
              }
            } else {
              Message.error({
                content: message,
                duration: 5000,
              })
            }
          })

          getUserList(pageData.filterList[0]['id'], 1)
        }
      }
      const insertType: any = ref(null)
      const tiaoJiXianZhi: any = ref(false)
      const tiaoJiXianZhi2: any = ref(false)
      const tiaoJiXianZhi3: any = ref(false)
      const insertHandleClick = () => {
        insertType.value = 2
        pageData.checkRyList = []
        pageData.checkBodyList = []
        pageData.checkHeadList = []
        pageData.getList = []
        pageData.bodyValueList = []
        pageData.editYgTime = []
        reSetAdjustment()
        reSetItemsoB()
        getlastTimeMaintainTypeList()
        searchMachine('')
        tiaoJiXianZhi.value = false
        tiaoJiXianZhi2.value = false
        tiaoJiXianZhi3.value = false
        visible.value = true
        getMaintenanceProject()
      }
      let isType: any = null
      // 渲染table的数据 打开第二层弹窗
      const cxTable = (type: any) => {
        // cascaderRef.value.resetForm()
        pageData.ygName = ''
        pageData.ygNameList = []
        pageData.firmId = ''
        pageData.applyBranchId = ''
        visible1.value = true
        pageData.checkBodyList = []
        pageData.checkHeadList = []
        pageData.getList = []
        pageData.bodyValueList = []
        pageData.firmList = []
        pageData.ygTypeList = []
        pageData.ygNameList = []
        pageData.firmId = null
        pageData.ygType = null
        pageData.ygName = null
        isType = type
      }
      let modalLoading = false
      const handleBeforeOk = async () => {
        var num = 0
        pageData.checkRyList.forEach(function (o) {
          num += parseFloat(o['ratio'])
        })
        if (
          pageData.adjustment['maintainType'] == '' ||
          pageData.adjustment['maintainType'] == undefined ||
          pageData.adjustment['maintainType'] == null
        ) {
          Message.warning({
            content: '调机类型必填！',
            duration: 2000,
          })
          return
        }
        modalLoading = true
        if (insertType.value == 1) {
          if (pageData.isXq1 == true) {
            if (pageData.adjustment['adjustmentState'] == 0) {
              pageData.adjustment['adjustmentState'] = 1
            }
          }
          //compareObj(pageData.adjustment, originData）只修改了调机类型 或者什么都没修改 传参多传一个 后端绕过校验
          post({
            url: 'planSingle/adjustment/dispatch',
            data: {
              adjustment: pageData.adjustment,
              userList: pageData.checkRyList,
              adjustmentStandard: itemsoB,
              upkeepList: [],
              machineCodeState: compareObj(pageData.adjustment, originData) ? 0 : null,
            },
          }).then(({ code, data, message }: any) => {
            if (code === 200) {
              Message.success('成功')
              visible.value = false
              doRefresh()
              pageData.isXq1 = false
              modalLoading = false
              // selectedRowKeys.value = [];
            } else {
              Message.error({
                content: message,
                duration: 5000,
              })
            }
          })
        } else {
          let upkeepList = []
          const isValid = await formRef1.value.validate()
          if (!isValid) {
            if (
              pageData.adjustment['firm'] == '' ||
              pageData.adjustment['firm'] == undefined ||
              pageData.adjustment['firm'] == null
            ) {
              //如果为空 从机台号下拉框接口那边去取 firmData {}
              pageData.adjustment['firm'] = firmData['firm']
            }
            if (
              pageData.adjustment['firmId'] == '' ||
              pageData.adjustment['firmId'] == undefined ||
              pageData.adjustment['firmId'] == null
            ) {
              //如果为空 从机台号下拉框接口那边去取 firmData {}
              pageData.adjustment['firmId'] = firmData['firmId']
            }
            post({
              url: 'planSingle/adjustment/insertDispatch',
              data: {
                adjustment: pageData.adjustment,
                userList: pageData.checkRyList,
                adjustmentStandard: itemsoB,
                upkeepList: [],
              },
            }).then(({ code, data, message }: any) => {
              if (code === 200) {
                Message.success('成功')
                visible.value = false
                doRefresh()
                pageData.isXq1 = false
                modalLoading = false
                // selectedRowKeys.value = [];
              } else {
                Message.error({
                  content: message,
                  duration: 5000,
                })
              }
            })
          }
        }
      }
      const handleCancel = () => {
        visible.value = false
        pageData.isXq1 = false
      }
      const handleBeforeOkSH = () => {
        var num = 0
        pageData.checkRyList.forEach(function (o) {
          num += parseFloat(o['ratio'])
        })
        post({
          url: 'planSingle/adjustment/dispatch',
          data: {
            adjustment: pageData.adjustment,
            userList: pageData.checkRyList,
            adjustmentStandard: itemsoB,
            machineCodeState: compareObj(pageData.adjustment, originData) ? 0 : null,
            upkeepList: [],
          },
        }).then(({ code, data, message }: any) => {
          if (code === 200) {
            visibleSH.value = false
            booleanSH.value = false
            selectHandler()
            doRefresh()
          } else {
            Message.error({
              content: message,
              duration: 5000,
            })
          }
        })
      }
      const handleCancelSH = () => {
        visibleSH.value = false
        booleanSH.value = false
      }
      // let tableId = 1
      let tableId: any = ref(1)
      //获取调机待确认页签权限
      const getTjdqrPermission = () => {
        if (permissionStore.hasPermisson('tjpg.tjdqdcx')) {
          pageData.btnList.push('查询')
        }
        if (permissionStore.hasPermisson('tjpg.tjpgdqdzjbzqd')) {
          pageData.btnList.push('调机发布')
        }
        if (permissionStore.hasPermisson('tjpg.tjpgdqdzjbzqd')) {
          pageData.btnList.push('转单发布')
        }
      }
      //获取调机待确认页签权限
      const getJqdqdPermission = () => {
        if (permissionStore.hasPermisson('tjpg.tjdqdcx')) {
          pageData.btnList.push('查询')
        }
        if (permissionStore.hasPermisson('tjpg.tjpgdqdzjbzqd')) {
          pageData.btnList.push('班长确定')
        }
      }
      const isTjrwEdit = ref<boolean>(true)
      const isTjrwFinish = ref<boolean>(true)
      //获取调机任务页签权限
      const getTjrwPermission = () => {
        if (permissionStore.hasPermisson('tjpg.tjrwcx')) {
          pageData.btnList.push('查询')
        }
        if (permissionStore.hasPermisson('tjpg.tjrwpg')) {
          pageData.btnList.push('派工')
        }
        if (permissionStore.hasPermisson('tjpg.tjrwxz')) {
          pageData.btnList.push('新增')
        }
        if (permissionStore.hasPermisson('tjpg.tjrwxg')) {
          //调机任务修改
          isTjrwEdit.value = false
        }
        if (permissionStore.hasPermisson('tjpg.tjrwwj')) {
          //调机任务完结
          isTjrwFinish.value = false
        }
      }
      const isJjdqrConfirm = ref<boolean>(true)
      //交机待确认页签权限
      const getJjdqrPermission = () => {
        if (permissionStore.hasPermisson('tjpg.jjdqdcx')) {
          pageData.btnList.push('查询')
        }
        if (permissionStore.hasPermisson('tjpg.jjdqdjjqd')) {
          //交机确认
          isJjdqrConfirm.value = false
        }
      }
      const isTjshDetail = ref<boolean>(true)
      const isTjshCancel = ref<boolean>(true)
      //调机审核页签权限
      const getTjshPermission = () => {
        if (permissionStore.hasPermisson('tjpg.tjshcx')) {
          pageData.btnList.push('查询')
        }
        if (permissionStore.hasPermisson('tjpg.tjshsh')) {
          pageData.btnList.push('审核')
        }
        if (permissionStore.hasPermisson('tjpg.tjshxq')) {
          //调机审核详情
          isTjshDetail.value = false
        }
        if (permissionStore.hasPermisson('tjpg.tjshqxwj')) {
          //调机审核取消完结
          isTjshCancel.value = false
        }
      }
      //已调机 未调机tab切换
      const changeTabs = (key: any) => {
        pageData.btnList = []
        tableId.value = key
        console.log(tableId.value)
        if (key == 2) {
          pageData.adjustmentState = ''
          pageData.accomplishState = 0
          doRefresh()
          getTjrwPermission()
        } else if (key == 3) {
          pageData.adjustmentState = '3,4'
          pageData.accomplishState = 0
          doRefresh()
          getJjdqrPermission()
        } else if (key == 1) {
          paginations1.page = 1
          doRefresh4()
          getTjdqrPermission()
        } else if (key == 4) {
          pageData.adjustmentState = ''
          pageData.accomplishState = 1
          doRefresh()
          getTjshPermission()
        }
      }
      //弹出员工框
      const visible1 = ref(false)
      const handleCancel1 = () => {
        visible1.value = false
      }
      //选择人员的确定按钮
      const handleOk = () => {
        // 员工类型
        // var typeList = pageData.ygTypeList.filter(function (o) {
        //     return pageData.ygType == o["id"]
        // })
        var nameList = pageData.ygNameList.filter(function (o) {
          return pageData.ygName == o['id']
        })
        if (isType == 0) {
          adjustment['sampleStaffId'] = pageData.ygName
          adjustment['sampleStaff'] = nameList[0]['name']
        } else {
          var ob = {}

          //员工类型
          ob['idType'] = pageData.ygType
          // ob["typeName"] = typeList[0]["post"];
          //员工名称
          ob['employeeId'] = pageData.ygName
          ob['employeeName'] = nameList[0]['name']
          ob['employeeCode'] = nameList[0]['code']
          ob['ratio'] = 0
          ob['allocationAmount'] = 0
          pageData.checkRyList.push(ob)
        }
      }
      //获取公司信息
      const getFirmList = () => {
        post({
          url: 'org/baCompany/getTreeCompanyByUser',
        }).then((res) => {
          if (res.code == 200) {
            pageData.firmList = JSON.parse(res.data)
            pageData.ygTypeList = []
            pageData.ygNameList = []
          } else {
            Message.error({
              content: '获取公司信息失败',
              duration: 5000,
            })
          }
        })
      }
      //获取员工岗位
      const getYgType = () => {
        post({
          url: '/hr/post/getAllActivePost',
          data: { id: pageData.firmId },
        }).then((res) => {
          if (res.code == 200) {
            pageData.ygTypeList = JSON.parse(res.data)
            pageData.ygNameList = []
          } else {
            Message.error({
              content: '查询员工岗位失败',
              duration: 5000,
            })
          }
        })
      }
      //获取员工名称
      const getYgName = () => {
        getAllNickname('')
      }

      const options6 = ref(pageData.ygNameList)
      const loading6 = ref(false)

      const handleSearch6 = (value: any) => {
        if (value) {
          loading6.value = true
          getAllNickname(value)
          loading6.value = false
        } else {
          options.value = []
        }
      }
      let a1 = [
        {
          showRowGroup: 'hide_def',
          headerName: '',
          checkboxSelection: true,
          headerCheckboxSelection: true,
          pinned: 'left',
          width: 50,
          resizable: false,
          filter: false,
          sortable: false,
          minWidth: 50,
          maxWidth: 50,
          lockPosition: 'left',
        },
      ]

      //查所有的员工
      function getAllNickname(val: any) {
        post({
          url: 'org/hrEmployee/getUserAndSecondment',
          data: {
            department_id: pageData.departmentId,
            workTime: pageData.adjustment['startTime'].slice(0, 10),
          },
        }).then((res) => {
          if (res.code == 200) {
            pageData.ygNameList = res.data
          } else {
            Message.error({
              content: '查询员工名称失败',
              duration: 5000,
            })
          }
        })
      }

      //获取当前登录账号
      const getUserToken = () => {
        post({
          url: 'admin/acl/user/findUserToken',
        }).then((res: any) => {
          if (res.code === 200) {
            pageData.departmentId = res.data.data.departmentId
          }
        })
      }

      //公司下拉框改变 员工岗位可选
      const changeFrim = () => {
        pageData.isShow = false
      }
      const changeType = () => {
        pageData.isShow1 = false
      }

      //最后调机类型下拉框
      function getlastTimeMaintainTypeList() {
        post({
          url: 'pieceData/adjustingMachinePrice/getList',
          data: {
            deletestate: 0,
          },
        }).then(({ code, data, message }: any) => {
          if (code === 200) {
            pageData.lastTimeMaintainTypeList = data
            pageData.maintainTypeList = data
          } else {
            Message.error({
              content: message,
              duration: 5000,
            })
          }
        })
      }
      /**
       *
       * 修改弹窗 调机类型 需要过滤掉转机
       */
      const filterMaintainTypeList = async () => {
        try {
          const res = await post({
            url: 'pieceData/adjustingMachinePrice/getList',
            data: { deletestate: 0, showState: 1 },
          })
          if (res.code == 200) {
            pageData.lastTimeMaintainTypeList = res.data
            pageData.maintainTypeList = res.data
          } else {
            Message.error({
              content: message,
              duration: 5000,
            })
          }
        } catch (e) {
          console.log(e)
        }
      }

      //调机比例大于100% 此单元格为0 并提示
      const changeRatio = (ratioNow: any) => {
        var num = 0
        pageData.checkRyList.forEach(function (o) {
          num += parseFloat(o['ratio'])
        })
        if (num > 100) {
          setTimeout(() => {
            Message.error({
              content: '此列数据和超过100,请重新输入！',
              duration: 2000,
            })
            ratioNow['ratio'] = 0
          }, 100)
        }
      }
      const visible2 = ref(false)
      //打印派工单
      const printPgd = () => {
        visible2.value = true
      }
      const printOk = () => {
        printJS({
          printable: 'spediz',
          type: 'html',
          targetStyles: ['*'],
        })
      }
      const handleCancel2 = () => {
        visible2.value = false
      }
      //设置权限
      // ['查询', '新增', '删除', '导出', '导入']
      const permissionStore = usePermission()
      //获取公司部门组列表
      const getFirmGroup = () => {
        post({
          url: 'org/baCompany/getTreeCompanyByUser',
        }).then(({ code, data }) => {
          if (code === 200) {
            pageData.firmList = data
          }
        })
      }
      const defaultColDef = {
        sortable: true,
        resizable: true,
        filter: true,
        // flex: 1
      }
      const defaultColDef2 = {
        sortable: true,
        resizable: true,
        filter: true,
        // flex: 1
      }
      const defaultColDef4 = {
        sortable: true,
        resizable: true,
        filter: true,
        // flex: 1
      }
      const defaultColDef5 = {
        sortable: true,
        resizable: true,
        filter: true,
        // flex: 1
      }
      let tc1: any[] = tableColumns.map((o) => {
        let obj = {
          headerName: o.title,
          field: o.key,
          pinned: o['fixed'],
          tooltipField: o.key,
        }
        if (o.slotName === 'suspendState') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'left'
          ;(obj['width'] = 120),
            (obj['cellRenderer'] = {
              template: `
                <el-tag v-if="a==0" type="success">未暂停</el-tag>
                <el-tag v-if="a==1" type="warning">等待暂停</el-tag>
                <el-tag v-if="a==2" type="warning">生产中暂停</el-tag>
              `,
              setup(props: any) {
                return {
                  a: props.params.data.suspendState,
                }
              },
            })
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '1'
                ? '等待暂停'
                : params.value == '0'
                ? '未暂停'
                : params.value == '2'
                ? '生产中暂停'
                : ''
            },
          }
        }
        if (o.slotName === 'maintainType') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag :type="val">{{ params.data.maintainType }}</el-tag>

            </a-space>
          `,
            setup(props: any) {
              let val = ref()
              if (props.params.data.maintainType == '转单') {
                val.value = ''
              } else if (props.params.data.maintainType == '改纱长') {
                val.value = 'success'
              } else if (props.params.data.maintainType == '改三角') {
                val.value = 'info'
              } else if (props.params.data.maintainType == '换针筒') {
                val.value = 'warning'
              } else if (props.params.data.maintainType == '转配套') {
                val.value = 'danger'
              }

              return {
                val,
              }
            },
          }
        }
        if (o.slotName === 'adjustmentState') {
          obj['resizable'] = false
          obj['filter'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 150
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag type="warning" v-if="params.data.adjustmentState==1">{{ val }}</el-tag>
              <el-tag type="success" v-else>{{ val }}</el-tag>
            </a-space>
          `,
            setup(props: any) {
              let val = ref()
              if (
                props.params.data.inspectionState == 2 &&
                props.params.data.adjustmentState != 4 &&
                props.params.data.adjustmentState != 3
              ) {
                val.value = '已查布头'
              } else if (props.params.data.adjustmentState == 1) {
                val.value = '已派工'
              } else if (props.params.data.adjustmentState == 0) {
                val.value = '未派工'
              } else if (props.params.data.adjustmentState == 2) {
                val.value = '调机中'
              } else if (props.params.data.adjustmentState == 3) {
                val.value = '已反馈'
              } else if (props.params.data.adjustmentState == 4) {
                val.value = '已交机'
              }
              return {
                val,
              }
            },
          }
        }
        if (o.slotName === 'craftState') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag type="success">{{ val }}</el-tag>
            </a-space>
          `,
            setup(props: any) {
              let val = ref()
              if (props.params.data.craftState == 1) {
                val.value = 'OK'
              } else if (props.params.data.craftState == 2) {
                val.value = '不OK'
              } else {
                val.value = '未检验'
              }
              return {
                val,
              }
            },
          }
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '1' ? 'OK' : params.value == '2' ? '不OK' : '未检验'
            },
          }
        }
        if (o.slotName === 'act') {
          obj['resizable'] = false
          obj['filter'] = false
          obj['sortable'] = false
          obj['lockPosition'] = 'right'
          obj['width'] = 150
          obj['cellRenderer'] = {
            template: `
            <a-spece>
              <el-button :style="{color:isTjrwEdit?'#999':'#165dff'}" link @click="edit" :disabled="isTjrwEdit">修改
              </el-button>
              <el-button :style="{color:isTjrwFinish?'#999':'#165dff'}" link @click="wanjie" :disabled="isTjrwFinish">
                完结
              </el-button>
            </a-spece>
          `,
            setup(props: any) {
              const edit = () => {
                if (props.params.data.maintainType === '转单') {
                  Message.warning({
                    content: '转单状态下不允许修改！',
                    duration: 5000,
                  })
                  return
                }
                tiaoJiXianZhi.value = false
                tiaoJiXianZhi2.value = false
                tiaoJiXianZhi3.value = false
                if (
                  props.params.data.adjustmentState != 1 &&
                  props.params.data.adjustmentState != 0
                ) {
                  tiaoJiXianZhi.value = true
                  // tiaoJiXianZhi2.value = true
                  tiaoJiXianZhi2.value = false
                  tiaoJiXianZhi3.value = true
                  pageData.isXq1 = false
                } else if (props.params.data.adjustmentState == 1) {
                  tiaoJiXianZhi.value = true
                  // tiaoJiXianZhi2.value = true
                  tiaoJiXianZhi2.value = false
                  pageData.isXq1 = true
                } else if (props.params.data.adjustmentState == 0) {
                  tiaoJiXianZhi.value = true
                  tiaoJiXianZhi3.value = true
                  pageData.isXq1 = false
                }
                handleClick(props.params.data)
              }
              const wanjie = () => {
                tempFinishId = props.params.data.id
                if(props.params.data.maintainType == '洗机'){
                  finishModalVisible.value = false
                  handleFinishOk('1')
                }else{
                  finishModalVisible.value = true
                }
              }
              return {
                edit,
                wanjie,
                isTjrwEdit,
                isTjrwFinish,
              }
            },
          }
        }

        return obj
      })

      tc1 = a1.concat(tc1)
      let tc2: any[] = tableColumnsChecked.map((o) => {
        let obj = {
          headerName: o.title,
          field: o.key,
          pinned: o['fixed'],
          tooltipField: o.key,
        }
        if (o.slotName === 'action') {
          obj['resizable'] = false
          obj['filter'] = false
          obj['sortable'] = false
          obj['width'] = 110
          // obj['lockPosition'] = 'right'
          obj['cellRenderer'] = {
            template: `
            <a-spece>
              <el-button style="color:#ccc" link @click="a"
                         v-if="e && c==1&&(maintainType!=='改三角'&&maintainType!=='换针筒'&&maintainType!=='转配套'&&maintainType!=='洗机')"
                         :disabled="c==1">
                交机确认
              </el-button>
              <el-button style="color:#165dff" link @click="a"
                         v-if="e && c!=1&&(maintainType!=='改三角'&&maintainType!=='换针筒'&&maintainType!=='转配套'&&maintainType!=='洗机')">
                交机确认
              </el-button>
              <el-button style="color:#165dff" link @click="showCheckTable"
                         v-if="e && c!=1&&(maintainType=='改三角'||maintainType=='换针筒'||maintainType=='转配套'||maintainType=='洗机')">
                交机确认
              </el-button>
              <el-button style="color:#165dff" link @click="showCheckTableDetail"
                         v-if="e && c==1&&(maintainType=='改三角'||maintainType=='换针筒'||maintainType=='转配套'||maintainType=='洗机')">
                点检表
              </el-button>
            </a-spece>  `,
            setup(props: any) {
              const a = () => {
                editHandler(props.params.data)
              }
              const showCheckTable = () => {
                checkTableShow(props.params.data)
              }
              const showCheckTableDetail = () => {
                checkTableDetailShow(props.params.data)
              }
              return {
                e: permissionStore.hasPermisson('tjpg.jjdqdjjqd'),
                a,
                c: props.params.data.monitorState,
                maintainType: props.params.data.maintainType,
                showCheckTable,
                showCheckTableDetail,
              }
            },
          }
        }
        if (o.slotName === 'maintainType') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag :type="val">{{ params.data.maintainType }}</el-tag>

            </a-space>
          `,
            setup(props: any) {
              let val = ref()
              if (props.params.data.maintainType == '转单') {
                val.value = ''
              } else if (props.params.data.maintainType == '改纱长') {
                val.value = 'success'
              } else if (props.params.data.maintainType == '改三角') {
                val.value = 'info'
              } else if (props.params.data.maintainType == '换针筒') {
                val.value = 'warning'
              } else if (props.params.data.maintainType == '转配套') {
                val.value = 'danger'
              }

              return {
                val,
              }
            },
          }
        }
        if (o.slotName === 'craftState') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag type="success">{{ val }}</el-tag>
            </a-space>
          `,
            setup(props: any) {
              let val = ref()
              if (props.params.data.craftState == 1) {
                val.value = 'OK'
              } else if (props.params.data.craftState == 2) {
                val.value = '不OK'
              } else {
                val.value = '未检验'
              }
              return {
                val,
              }
            },
          }
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '1' ? 'OK' : params.value == '2' ? '不OK' : '未检验'
            },
          }
        }

        if (o.slotName === 'drawnNeedleState') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `<span>{{ a }}</span>`,
            setup(props: any) {
              return {
                a: props.params.data.drawnNeedleState == 0 ? '抽针' : '圆筒',
              }
            },
          }
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '0' ? '抽针' : '圆筒'
            },
          }
        }

        if (o.slotName === 'widthState') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `<span>{{ a }}</span>`,
            setup(props: any) {
              return {
                a: props.params.data.widthState == 0 ? '不开幅' : '开幅',
              }
            },
          }
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '0' ? '不开幅' : '开幅'
            },
          }
        }

        if (o.slotName === 'accomplishState') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `<span>{{ a }}</span>`,
            setup(props: any) {
              return {
                a: props.params.data.accomplishState == 0 ? '否' : '是',
              }
            },
          }
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '0' ? '否' : '是'
            },
          }
        }
        return obj
      })

      let a2 = [
        {
          showRowGroup: 'hide_def',
          headerName: '',
          checkboxSelection: true,
          headerCheckboxSelection: true,
          pinned: 'left',
          width: 50,
          resizable: false,
          filter: false,
          sortable: false,
          minWidth: 50,
          maxWidth: 50,
          lockPosition: 'left',
        },
      ]
      tc2 = a2.concat(tc2)
      const tableColumns4 = useTableColumn([
        {
          title: '公司',
          key: 'firm',
          dataIndex: 'firm',
          width: 150,
        },
        {
          title: '调机单号',
          key: 'adjustmentCode',
          dataIndex: 'adjustmentCode',
          width: 150,
        },
        {
          title: '机台号',
          key: 'machineCode',
          dataIndex: 'machineCode',
          width: 150,
        },
        {
          title: '生产单号',
          key: 'weaveCode',
          dataIndex: 'weaveCode',
          width: 150,
        },
        {
          title: '织布单号',
          key: 'planOrderCode',
          dataIndex: 'planOrderCode',
          width: 150,
        },
        {
          title: '坯布编号',
          key: 'greyCode',
          dataIndex: 'greyCode',
          width: 150,
        },

        {
          title: '坯布名称',
          key: 'grayName',
          dataIndex: 'grayName',
          width: 150,
        },

        {
          title: '客户名称',
          key: 'customName',
          dataIndex: 'customName',
          width: 150,
        },

        {
          title: '楼层',
          key: 'storey',
          dataIndex: 'storey',
          width: 150,
        },
        {
          title: '备注',
          key: 'remark',
          dataIndex: 'remark',
          width: 150,
        },
        {
          title: '调机类型',
          key: 'maintainType',
          dataIndex: 'maintainType',
          slotName: 'maintainType',
          width: 200,
          // fixed: 'right',
        },
        {
          title: '调机日期',
          key: 'startTime',
          dataIndex: 'startTime',
          width: 200,
        },
      ])
      let tc4: any[] = tableColumns4.map((o) => {
        let obj = {
          headerName: o.title,
          field: o.key,
          pinned: o['fixed'],
          tooltipField: o.key,
        }
        if (o.slotName === 'maintainType') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag :type="val">{{ params.data.maintainType }}</el-tag>

            </a-space>
          `,
            setup(props: any) {
              let val = ref()
              if (props.params.data.maintainType == '转单') {
                val.value = ''
              } else if (props.params.data.maintainType == '改纱长') {
                val.value = 'success'
              } else if (props.params.data.maintainType == '改三角') {
                val.value = 'info'
              } else if (props.params.data.maintainType == '换针筒') {
                val.value = 'warning'
              } else if (props.params.data.maintainType == '转配套') {
                val.value = 'danger'
              }

              return {
                val,
              }
            },
          }
        }

        return obj
      })
      tc4 = a1.concat(tc4)
      const tableColumns5 = useTableColumn([
        {
          title: '公司',
          key: 'firm',
          dataIndex: 'firm',
          width: 150,
        },
        {
          title: '调机单号',
          key: 'adjustmentCode',
          dataIndex: 'adjustmentCode',
          width: 150,
        },
        {
          title: '机台号',
          key: 'machineCode',
          dataIndex: 'machineCode',
          width: 150,
        },
        {
          title: '生产单号',
          key: 'weaveCode',
          dataIndex: 'weaveCode',
          width: 150,
        },
        {
          title: '织布单号',
          key: 'planOrderCode',
          dataIndex: 'planOrderCode',
          width: 150,
        },
        {
          title: '坯布编号',
          key: 'greyCode',
          dataIndex: 'greyCode',
          width: 150,
        },

        {
          title: '坯布名称',
          key: 'grayName',
          dataIndex: 'grayName',
          width: 150,
        },

        {
          title: '客户名称',
          key: 'customName',
          dataIndex: 'customName',
          width: 150,
        },

        {
          title: '楼层',
          key: 'storey',
          dataIndex: 'storey',
          width: 150,
        },

        {
          title: '调机类型',
          key: 'maintainType',
          dataIndex: 'maintainType',
          slotName: 'maintainType',
          width: 200,
          // fixed: 'right',
        },
        {
          title: '工艺复核',
          key: 'craftState',
          dataIndex: 'craftState',
          slotName: 'craftState',
          width: 200,
          // fixed: 'right',
        },
        {
          title: '审核状态',
          key: 'auditState',
          dataIndex: 'auditState',
          slotName: 'auditState',
          width: 150,
          // fixed: 'right',
        },
        {
          title: '调机状态',
          key: 'diaoJiState',
          dataIndex: 'diaoJiState',
          slotName: 'diaoJiState',
          width: 150,
          fixed: 'right',
        },
        {
          title: '操作',
          key: 'id',
          dataIndex: 'id',
          slotName: 'act',
          width: 150,
          fixed: 'right',
        },
      ])
      let tc5: any[] = tableColumns5.map((o) => {
        let obj = {
          headerName: o.title,
          field: o.key,
          pinned: o['fixed'],
          tooltipField: o.key,
        }
        if (o.slotName === 'maintainType') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag :type="val">{{ params.data.maintainType }}</el-tag>

            </a-space>
          `,
            setup(props: any) {
              let val = ref()
              if (props.params.data.maintainType == '转单') {
                val.value = ''
              } else if (props.params.data.maintainType == '改纱长') {
                val.value = 'success'
              } else if (props.params.data.maintainType == '改三角') {
                val.value = 'info'
              } else if (props.params.data.maintainType == '换针筒') {
                val.value = 'warning'
              } else if (props.params.data.maintainType == '转配套') {
                val.value = 'danger'
              }

              return {
                val,
              }
            },
          }
        }
        if (o.slotName === 'diaoJiState') {
          obj['resizable'] = false
          obj['filter'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 150
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag type="warning" v-if="params.data.adjustmentState==1">{{ val }}</el-tag>
              <el-tag type="success" v-else>{{ val }}</el-tag>
            </a-space>
          `,
            setup(props: any) {
              let val = ref()
              if (
                props.params.data.inspectionState == 2 &&
                props.params.data.adjustmentState != 4 &&
                props.params.data.adjustmentState != 3
              ) {
                val.value = '已查布头'
              } else if (props.params.data.adjustmentState == 1) {
                val.value = '已派工'
              } else if (props.params.data.adjustmentState == 0) {
                val.value = '未派工'
              } else if (props.params.data.adjustmentState == 2) {
                val.value = '调机中'
              } else if (props.params.data.adjustmentState == 3) {
                val.value = '已反馈'
              } else if (props.params.data.adjustmentState == 4) {
                val.value = '已交机'
              }
              return {
                val,
              }
            },
          }
        }
        if (o.slotName === 'adjustmentState') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag type="warning" v-if="params.data.adjustmentState==1">{{ val }}</el-tag>
              <el-tag type="success" v-else>{{ val }}</el-tag>
            </a-space>
          `,
            setup(props: any) {
              let val = ref()
              if (props.params.data.adjustmentState == 1) {
                val.value = '已派工'
              } else {
                val.value = '未派工'
              }

              return {
                val,
              }
            },
          }
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '1' ? '已派工' : '未检验'
            },
          }
        }
        if (o.slotName === 'craftState') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag type="success">{{ val }}</el-tag>
            </a-space>
          `,
            setup(props: any) {
              let val = ref()
              if (props.params.data.craftState == 1) {
                val.value = 'OK'
              } else if (props.params.data.craftState == 2) {
                val.value = '不OK'
              } else {
                val.value = '未检验'
              }
              return {
                val,
              }
            },
          }
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '1' ? 'OK' : params.value == '2' ? '不OK' : '未检验'
            },
          }
        }
        if (o.slotName === 'act') {
          obj['resizable'] = false
          obj['filter'] = false
          obj['sortable'] = false
          obj['lockPosition'] = 'right'
          obj['width'] = 150
          obj['cellRenderer'] = {
            template: `
            <a-spece>
              <el-button style="color:#165dff" link @click="CancelComplet" v-if='show&& params.data.auditState!=1'>
                修改
              </el-button>
              <el-button style="color:#ccc" link :disabled='params.data.auditState==1'
                         v-if='show && params.data.auditState==1'>修改
              </el-button>
              <el-button :style="{color:isTjshDetail?'#999':'#165dff'}" link @click="edit" :disabled="isTjshDetail">
                详情
              </el-button>
            </a-spece>
          `,
            setup(props: any) {
              const edit = () => {
                let ob = props.params.data
                ob['xq'] = true
                handleClick(ob)
              }
              const CancelComplet = () => {
                booleanSH.value = true
                // CancelCompletion(props.params.data)
                handleClick(props.params.data)
              }
              return {
                edit,
                CancelComplet,
                show: permissionStore.hasPermisson('tjpg.tjshqxwj'),
                isTjshDetail,
              }
            },
          }
        }
        if (o.slotName === 'auditState') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 110
          obj['cellRenderer'] = {
            template: `
            <a-space>
              <el-tag type="warning" v-if="params.data.auditState==0">未审核</el-tag>
              <el-tag type="success" v-if="params.data.auditState==1">已审核</el-tag>
            </a-space>
          `,
            setup(props: any) {
              return {}
            },
          }
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '0' ? '未审核' : params.value == '1' ? '已审核' : ''
            },
          }
        }

        return obj
      })
      let a5 = [
        {
          showRowGroup: 'hide_def',
          headerName: '',
          checkboxSelection: true,
          headerCheckboxSelection: true,
          pinned: 'left',
          width: 50,
          resizable: false,
          filter: false,
          sortable: false,
          minWidth: 50,
          maxWidth: 50,
          lockPosition: 'left',
        },
      ]
      tc5 = a5.concat(tc5)

      const localeText1: any = ref(localeText)
      const huiche = () => {
        doRefresh()
      }
      const pagingList1: any = ref(pagingList)

      function changeJx(val: any) {}

      //获取保养项目
      const getMaintenanceProject = () => {
        try {
          post({
            url: '/zcTemRepair/upkeep/getList',
            data: { upkeepName: '洗机' },
          }).then((res) => {
            if (res.code == 200) {
              table1Ref.value.setdataListIterface(res.data)
            } else {
              ElMessage.error(res.message)
            }
          })
        } catch (e: any) {
          console.log(e)
        }
      }
      //预防保存的时候没有公司id和公司名称 如果没有 从机台号下拉接口这边去取
      let firmData = {}
      let tempSearchData: any = []

      async function changeMachine(val: any) {
        pageData.checkRyList = []
        pageData.checkBodyList = []
        pageData.checkHeadList = []
        pageData.getList = []
        pageData.bodyValueList = []
        pageData.editYgTime = []
        pageData.adjustment['weaveCode'] = ''
        pageData.weaveCodeList = []
        if (val != '') {
          await searchMachine(val)
          console.log('1010', tempSearchData)
          const storey = tempSearchData.find((item: any) => item.machineCode == val)
          if (storey) {
            pageData.adjustment['storey'] = storey['areaName']
            pageData.adjustment['machineId'] = storey['machineId']
          }
          if (tempSearchData.length == 1)
            pageData.adjustment['machineId'] = tempSearchData[0].machineId
          get({
            url: `/planSingle/adjustment/getPlanOrderByMachineCode?machineCode=${val}`,
          }).then(({ code, data, message }: any) => {
            if (code === 200) {
              var resultAdjustment = data.adjustment
              //删除调不需要的字段
              delete resultAdjustment['storey']
              delete resultAdjustment['maintainType']
              // delete resultAdjustment['weaveCode']
              for (const key in resultAdjustment) {
                if (key === 'adjustmentRatio') {
                  resultAdjustment[key] = parseFloat(resultAdjustment[key])
                }
                if (key === 'adjustmentWeight' && resultAdjustment[key] === null) {
                  resultAdjustment[key] = 0
                }
                if (key === 'sampleWeight' && resultAdjustment[key] === null) {
                  resultAdjustment[key] = 0
                }
                if (key !== 'machineId') pageData.adjustment[key] = resultAdjustment[key]
              }
              //派工 员工
              if (data['userList'].length > 0) {
                pageData.checkRyList = data['userList']
                pageData.checkRyList.forEach(function (o: any) {
                  o['allocationAmount'] = 0
                })
              }
              //调机项目
              if (data['adjustmentStandard'] != null && data['adjustmentStandard'] != '') {
                if (Object.keys(data['adjustmentStandard']).length > 0) {
                  for (let key in data['adjustmentStandard']) {
                    itemsoB[key] = data['adjustmentStandard'][key]
                  }
                }
              }
            } else {
              Message.error({
                content: message,
                duration: 5000,
              })
              reSetAdjustment()
              reSetItemsoB()
            }
          })
          const res = await get({
            url: `planSingle/adjustment/getWeaveCodeInfoByMachineCode?machineCode=${val}`,
          })
          if (res.code == 200) {
            pageData.weaveCodeList = res.data
          } else {
            ElMessage.error(res.message)
          }
        } else {
          searchMachine('')
          reSetAdjustment()
          reSetItemsoB()
        }
      }

      const searchMachine = async (val: any) => {
        return new Promise(async (resolve, reject) => {
          const res = await get({
            url: '/planSingle/adjustment/getMachineByAdjustment',
            data: {
              machineCode: val,
            },
          })
          if (res.code === 200) {
            tempSearchData = res.data
            console.log('tempSearchData', tempSearchData)
            pageData.machineList = res.data
            firmData['firmId'] = res.data[0].firmId
            firmData['firm'] = res.data[0].firm
            resolve(res.data)
          } else {
            Message.error({
              content: res.message,
              duration: 5000,
            })
            reject(res.message)
          }
        })
      }

      //设置权限
      // ['查询', '新增', '删除', '导出', '导入']

      // if (
      //   permissionStore.hasPermisson('tjpg.wtjpg') ||
      //   permissionStore.hasPermisson('tjpg.ytjpg')
      // ) {
      //   pageData.btnList.push('查询')
      // }
      // if (permissionStore.hasPermisson('zjpg.dqdzjbzqd')) {
      //   if (!pageData.btnList.includes('调机发布')) {
      //     pageData.btnList.push('调机发布')
      //   }
      // }
      // if (permissionStore.hasPermisson('tjpg.xz') && pageData.adjustmentState != '2') {
      //   pageData.btnList.push('新增')
      // }
      // if (permissionStore.hasPermisson('tjpg.pg') && pageData.adjustmentState != '2') {
      //   pageData.btnList.push('派工')
      // }
      //获取所有调机类型的方法
      const getMaintainTypeList = async () => {
        try {
          const res = await post({
            url: 'pieceData/adjustingMachinePrice/getList',
            data: {
              deletestate: 0,
            },
          })
          if (res.code == 200) {
            maintainTypeList1.value = res.data.filter((item: any) => item.machineTypeName != '转单')
          } else {
            Message.error({
              content: res.message,
              duration: 5000,
            })
          }
        } catch (error) {
          console.log(error)
        }
      }
      //保存修改调机类型的方法
      const saveMaintainType = async (data: any) => {
        try {
          const res = await post({
            url: 'planSingle/adjustment/updateDutyMonitorState',
            data,
          })
          console.log('res', res)
          if (res.code == 200) {
            Message.success({
              content: '发布成功！',
              duration: 5000,
            })
            editMaintainTypeVisible.value = false
            doRefresh4()
          } else {
            Message.error({
              content: res.message,
              duration: 5000,
            })
          }
        } catch (error) {
          console.log(error)
        }
      }

      //调机发布
      async function checkInMonitor() {
        if (gridOption4.value.getSelectedRows().length == 0) {
          Message.warning({
            content: '请先勾选！',
            duration: 5000,
          })
          return
        }
        if (
          gridOption4.value.getSelectedRows().length == 1 &&
          gridOption4.value.getSelectedRows()[0].maintainType == '转单'
        ) {
          await getMaintainTypeList()
          editMaintainTypeVisible.value = true
        } else if (
          gridOption4.value.getSelectedRows().length == 1 &&
          gridOption4.value.getSelectedRows()[0].maintainType !== '转单'
        ) {
          saveMaintainType({
            ids: gridOption4.value.getSelectedRows().map((o: any) => {
              return o['id']
            }),
            maintainType: undefined,
          })
        } else if (gridOption4.value.getSelectedRows().length > 1) {
          if (
            gridOption4.value.getSelectedRows().some((item: any) => item.maintainType == '转单') &&
            !gridOption4.value.getSelectedRows().every((item: any) => item.maintainType == '转单')
          ) {
            Message.warning({
              content: '转单不能和其他类型一起进行调机发布发布！',
              duration: 5000,
            })
            return
          } else {
            if (
              gridOption4.value.getSelectedRows().every((item: any) => item.maintainType == '转单')
            ) {
              await getMaintainTypeList()
              editMaintainTypeVisible.value = true
            } else {
              saveMaintainType({
                ids: gridOption4.value.getSelectedRows().map((o: any) => {
                  return o['id']
                }),
                maintainType: undefined,
              })
            }
          }
        }
      }

      //下拉框得到焦点  织针型号
      const needfocusSel = () => {
        needselCxAll({ specName: '' })
      }
      //下拉数据  织针型号
      const needoptions = ref<any>(pageData.nameList)
      const needloading = ref(false)
      const needhandleSearch = (value: any) => {
        if (value) {
          const ob = { specName: value }
          loading.value = true
          needselCxAll(ob)
          needoptions.value = pageData.nameList
          needloading.value = false
        } else {
          options.value = []
        }
      }

      //下拉框查询  织针型号
      function needselCxAll(val: any) {
        post({
          url: 'purchase/MaterialSpec/getFieldValue',
          data: val,
        }).then(({ data, code }: any) => {
          if (code === 200) {
            pageData.nameList = data
          } else {
            Message.error({
              content: '查询失败！',
              duration: 5000,
            })
          }
        })
      }

      //审核
      function auditData() {
        post({
          url: 'planSingle/adjustment/updateAuditStateByIds',
          data: gridOption5.value.getSelectedRows().map((o: any) => {
            return o['id']
          }),
        }).then(({ code, data, message }: any) => {
          if (code === 200) {
            Message.success({
              content: '审核成功！',
              duration: 5000,
            })
            doRefresh()
          } else {
            Message.error({
              content: message,
              duration: 5000,
            })
          }
        })
      }

      //取消完结
      function CancelCompletion(row: any) {
        // post({
        //   url: 'planSingle/adjustment/updateWanjieByIds',
        //   data: [row['id']]

        // }).then(({ code, data, message }: any) => {
        //   if (code === 200) {
        //     Message.success({
        //       content: "取消完结成功！",
        //       duration: 5000,
        //     })
        //     doRefresh()
        //   } else {
        //     Message.error({
        //       content: message,
        //       duration: 5000,
        //     })
        //   }
        // })
        post({
          url: 'planSingle/adjustment/completeAdjustmentOrder',
          data: {
            id: row.id,
            accomplishState: 0,
            adjustmentState: 2,
          },
        }).then(({ code, data, message }: any) => {
          if (code === 200) {
            Message.success({
              content: '取消完结成功！',
              duration: 5000,
            })
            doRefresh()
          } else {
            Message.error({
              content: message,
              duration: 5000,
            })
          }
        })
      }

      function cxDiscountPrice() {
        console.log(adjustment['maintainType'])
        post({
          url: 'pieceData/adjustingMachinePrice/getOneMachineTypePrice',
          data: {
            machineTypeName: pageData.adjustment['maintainType'],
            machineCode: pageData.adjustment['machineCode'],
            deletestate: 0,
          },
        }).then(({ code, data, message }: any) => {
          if (code === 200) {
            pageData.adjustment['discountPrice'] =
              data * (pageData.adjustment['adjustmentRatio'] / 100)
            //分配金额 计算  折扣单价*分配比例
            pageData.checkRyList.forEach(function (o) {
              o['allocationAmount'] =
                (Number(o['ratio']) / 100) * Number(pageData.adjustment['discountPrice'])
            })
          } else {
            Message.error({
              content: message,
              duration: 5000,
            })
          }
        })
      }

      const { saveGridState: saveGridState01, updateGridState: updateGridState01 } =
        saveOrUpdateGridState01('Spedizione-1', gridOption, colState, tc1)
      const onColumnMoved = () => {
        saveGridState01()
      }
      const onColumnResized = () => {
        saveGridState01()
      }
      const onColumnVisible = () => {
        saveGridState01()
      }
      const { saveGridState: saveGridState02, updateGridState: updateGridState02 } =
        saveOrUpdateGridState02('Spedizione-2', gridOption2, colState2, tc2)
      const onColumnMoved2 = () => {
        saveGridState02()
      }
      const onColumnResized2 = () => {
        saveGridState02()
      }
      const onColumnVisible2 = () => {
        saveGridState02()
      }
      const { saveGridState: saveGridState04, updateGridState: updateGridState04 } =
        saveOrUpdateGridState04('Spedizione-4', gridOption4, colState4, tc4)
      const onColumnMoved4 = () => {
        saveGridState04()
      }
      const onColumnResized4 = () => {
        saveGridState04()
      }
      const onColumnVisible4 = () => {
        saveGridState04()
      }
      const { saveGridState: saveGridState05, updateGridState: updateGridState05 } =
        saveOrUpdateGridState05('Spedizione-5', gridOption5, colState5, tc5)
      const onColumnMoved5 = () => {
        saveGridState05()
      }
      const onColumnResized5 = () => {
        saveGridState05()
      }
      const onColumnVisible5 = () => {
        saveGridState05()
      }
      //转单发布
      const sendSwitch = () => {
        if (gridOption4.value.getSelectedRows().length == 0) {
          Message.warning({
            content: '请先勾选！',
            duration: 5000,
          })
        } else {
          // const hasNonTransferMaintain = gridOption4.value.getSelectedRows().some((row: any) => row.maintainType === '转单');
          // if (hasNonTransferMaintain) {
          //   Message.warning({
          //     content: '调机类型为转单的调机单，不可以在进行调机发布！',
          //     duration: 5000,
          //   })
          // } else {
          visibleZdfb.value = true
          // }
        }
      }
      //转单发布弹窗
      const visibleZdfb = ref(false)
      const typeZdfb = ref(0)
      const handleOkZdfb = () => {
        const idList = gridOption4.value.getSelectedRows().map((o: any) => {
          return o['id']
        })
        const type = typeZdfb.value
        post({
          url: 'planSingle/adjustment/transferOrderByType',
          data: { idList, type },
        }).then(({ code, data, message }: any) => {
          if (code === 200) {
            Message.success({
              content: '转单发布成功！',
              duration: 5000,
            })
            visibleZdfb.value = false
            doRefresh4()
          } else {
            Message.error({
              content: message,
              duration: 5000,
            })
          }
        })
      }
      const handleCancelZdfb = () => {
        visibleZdfb.value = false
      }
      const isxqObjay = async (greyCloth: any) => {
        const { data } = await post({
          url: 'planSingle/machineStandard/getOntByGrey',
          data: {
            greyCloth,
          },
        })
        for (let key in data) {
          itemsoB1[key] = data[key]
        }
      }
      watch(
        () => visible.value,
        (l, o) => {
          if (l) {
            for (let key in itemsoB1) {
              itemsoB1[key] = null
            }
            nextTick(() => {
              if (adjustment['greyCode']) {
                isxqObjay(adjustment['greyCode'])
              }
            })
          }
        }
      )
      watch(
        () => adjustment['greyCode'],
        (l, o) => {
          nextTick(() => {
            if (l) {
              isxqObjay(l)
            }
          })
        }
      )

      const needleMpdelList = ref([])
      const needleMpdelClick = (val: any) => {
        post({
          url: '/purchase/MaterialInfo/getFieldValueByZhenYe',
          data: {
            specName: val,
          },
        }).then(({ data }) => {
          needleMpdelList.value = data
        })
      }
      const editMaintainTypeVisible = ref<boolean>(false)
      const editMaintainType: any = ref('')
      const maintainTypeList1 = ref<any>([])
      const handleEditMaintainTypeOk = () => {
        saveMaintainType({
          ids: gridOption4.value.getSelectedRows().map((o: any) => {
            return o['id']
          }),
          maintainType: editMaintainType.value,
        })
      }
      const handleEditMaintainTypeCancel = () => {
        editMaintainType.value = ''
      }
      watch(
        () => pageData.adjustment['greyCode'],
        async (newVal) => {
          if (newVal !== '') {
            const res = await post({
              url: 'product/pdGreyInformation/selectpdGreyInformation',
              data: {
                greyCode: newVal,
              },
            })
            if (res.code == 200) {
              pageData.adjustment['widthState'] = res.data[0].drawnNeedleState
              pageData.adjustment['drawnNeedleState'] = res.data[0].drawnNeedleState
            } else {
              ElMessage.error(res.message)
            }
          }
        }
      )
      const isDispatchWorkDetail = ref(false)
      const handleWeaveCodeChange = (e: any) => {
        if (e !== '') {
          const storey = pageData.adjustment['storey']
          const maintainType = pageData.adjustment['maintainType']
          const filterObj = pageData.weaveCodeList.find((item: any) => item.weaveCode == e)
          console.log('filterObj', filterObj)
          if (!filterObj['adjustmentWeight']) filterObj['adjustmentWeight'] = 0
          if (!filterObj['sampleWeight']) filterObj['sampleWeight'] = 0
          pageData.adjustment = JSON.parse(JSON.stringify(filterObj))
          pageData.adjustment['storey'] = storey
          pageData.adjustment['maintainType'] = maintainType
          if (tempSearchData.length == 1)
            pageData.adjustment['machineId'] = tempSearchData[0].machineId
        } else {
          pageData.adjustment['drawnNeedleState'] = '' //清空是否抽针
          pageData.adjustment['planOrderCode'] = '' //清空织布单号
          pageData.adjustment['customName'] = '' //清空客户名称
          pageData.adjustment['greyCode'] = '' //清空坯布编号
          pageData.adjustment['grayName'] = '' //清空坯布名称
          pageData.adjustment['widthState'] = '' //清空是否开幅
        }
      }
      const checkTableVisible = ref<boolean>(false)
      const checkBoxList = ref<any>([])
      const getCheckBoxList = async (data: any) => {
        const res = await post({
          url: 'planSingle/spotCheckProject/getInfoListByType',
          data: {
            machineCode: data.machineCode,
            adjustmentType: data.maintainType,
          },
        })
        try {
          if (res.code == 200) {
            checkBoxList.value = res.data.map((item: any) => {
              return {
                ...item,
                projectState: 1,
              }
            })
            console.log('checkBoxList', checkBoxList.value)
          } else {
            ElMessage.error(res.message)
          }
        } catch (e) {
          console.log(e)
        }
      }
      //选中的点检项目id数组
      const checkBoxIds = ref<any>([])
      //记录行的id 保存的时候要用
      let currentRowId: any
      //非转单点击交机确认 弹窗显示函数
      const checkTableShow = async (data: any) => {
        checkBoxIds.value = []
        currentRowId = data.id
        await getCheckBoxList(data)
        checkTableVisible.value = true
      }
      //非转单点击交机确认 弹窗确定函数
      const handleCheckTableOk = async () => {
        console.log('aaa', checkBoxIds.value)
        //构造传参
        const spotInfo = checkBoxList.value.map((item: any) => {
          if (checkBoxIds.value.includes(item.projectCode)) {
            return {
              projectCode: item.projectCode,
              projectName: item.projectName,
              projectState: 1,
            }
          } else {
            return {
              projectCode: item.projectCode,
              projectName: item.projectName,
              projectState: 0,
            }
          }
        })
        const res = await post({
          url: 'planSingle/adjustment/monitorConfirm',
          data: {
            adjustmentId: currentRowId,
            spotInfo: spotInfo ? spotInfo : [],
          },
        })
        try {
          if (res.code == 200) {
            ElMessage.success(res.message)
            checkTableVisible.value = false
            doRefresh()
          } else {
            ElMessage.error(res.message)
          }
        } catch (e) {
          console.log(e)
        }
      }
      const handleCheckTableCancel = () => {
        checkTableVisible.value = false
        checkBoxIds.value = []
      }
      const checkTableDetailVisible = ref<boolean>(false)
      const checkTableDetailShow = async (data: any) => {
        checkBoxList.value = []
        checkBoxIds.value = []
        const id = data.id
        const res = await get({
          url: `planSingle/adjustmentSpotInfo/getSpotInfoByAdjustmentId?adjustmentId=${id}`,
        })
        console.log('res', res)
        try {
          if (res.code == 200) {
            checkBoxList.value = res.data
            checkBoxList.value
              .filter((item: any) => item.projectState == 1)
              .forEach((item2: any) => {
                checkBoxIds.value.push(item2.projectCode)
              })
            checkTableDetailVisible.value = true
          } else {
            ElMessage.error(res.message)
          }
        } catch (e) {
          console.log(e)
        }
      }
      const handleCheckTableDetailCancel = () => {
        checkTableDetailVisible.value = false
        checkBoxList.value = []
        checkBoxIds.value = []
      }
      const finishModalVisible = ref<boolean>(false)
      const handleFinishOk = async (val: any) => {
        if (val === '0') {
          try {
            // val=0时 非洗机
            const res = await post({
              url: 'planSingle/adjustment/completeAdjustmentOrder',
              data: {
                id: tempFinishId,
                accomplishState: 1,
                adjustmentState: 3,
                washState: 0,
              },
            })
            if (res.code == 200) {
              ElMessage.success(res.message)
              finishModalVisible.value = false
              doRefresh()
            } else {
              ElMessage.error(res.message)
            }
          } catch (e) {
            console.log(e)
          }
        } else if (val === '1') {
          try {
            // val=1时 洗机
            const res = await post({
              url: 'planSingle/adjustment/completeAdjustmentOrder',
              data: {
                id: tempFinishId,
                accomplishState: 1,
                adjustmentState: 3,
                washState: 1,
              },
            })
            if (res.code == 200) {
              ElMessage.success(res.message)
              finishModalVisible.value = false
              doRefresh()
            } else {
              ElMessage.error(res.message)
            }
          } catch (e) {
            console.log(e)
          }
        }
      }
      const handleFinishCancel = () => {
        finishModalVisible.value = false
      }
      return {
        modalLoading,
        getUserToken,
        finishModalVisible,
        handleFinishOk,
        handleFinishCancel,
        checkTableDetailVisible,
        handleCheckTableDetailCancel,
        checkBoxIds,
        checkBoxList,
        checkTableVisible,
        checkTableShow,
        handleCheckTableOk,
        handleCheckTableCancel,
        handleWeaveCodeChange,
        formRef1,
        editMaintainTypeVisible,
        handleEditMaintainTypeOk,
        handleEditMaintainTypeCancel,
        maintainTypeList1,
        editMaintainType,
        needleMpdelClick,
        needleMpdelList,
        isxqObjay,
        saveOrUpdateGridState01,
        saveGridState01,
        updateGridState01,
        onColumnMoved,
        onColumnResized,
        onColumnVisible,
        colState,
        saveOrUpdateGridState02,
        saveGridState02,
        updateGridState02,
        onColumnMoved2,
        onColumnResized2,
        onColumnVisible2,
        colState2,
        saveOrUpdateGridState04,
        saveGridState04,
        updateGridState04,
        onColumnMoved4,
        onColumnResized4,
        onColumnVisible4,
        colState4,
        saveOrUpdateGridState05,
        saveGridState05,
        updateGridState05,
        onColumnMoved5,
        onColumnResized5,
        onColumnVisible5,
        colState5,
        tiaoJiXianZhi3,
        tiaoJiXianZhi2,
        tiaoJiXianZhi,
        auditData,
        needhandleSearch,
        needfocusSel,
        needloading,
        needoptions,
        paginations1,
        checkInMonitor,
        gridReady4,
        tc4,
        tableColumns4,
        defaultColDef4,
        tableColumns5,
        gridReady5,
        tc5,
        defaultColDef5,
        itemsoB1,
        changeJx,
        defaultColDef2,
        tableId,
        pagingList1,
        huiche,
        localeText1,
        total,
        tc2,
        tc1,
        defaultColDef,
        gridReady,
        gridReady2,
        sideOk,
        formRef,
        dataForm,
        addHandler,
        selectedRowKeys,
        configCascader,
        changeCascader,
        s: selectedRowKeysChecked.selectedRowKeys,
        pagination,
        tableColumns,
        table,
        rowKey,
        pageData,
        editHandler,
        selectHandler,
        // cascaderRef,
        tableColumnsChecked,
        changeTabs,
        handleClick,
        booleanSH,
        handleCancel,
        handleCancelSH,
        visible,
        visibleSH,
        handleBeforeOk,
        handleBeforeOkSH,
        options,
        loading,
        options6,
        loading6,
        pageData1,
        handleSearch,
        handleSearch1,
        handleSearch2,
        handleSearch3,
        handleSearch4,
        handleSearch5,
        handleSearch6,
        focusSel,
        headerShow,
        visible1,
        handleCancel1,
        handleOk,
        getYgType,
        getYgName,
        getFirmList,
        changeFrim,
        changeType,
        cxTable,
        delRow,
        changeRatio,
        printPgd,
        printJS,
        printOk,
        handleCancel2,
        visible2,
        adjustment,
        permissionStore,
        itemsoB,
        getFirmGroup,
        change1,
        PageSize,
        insertHandleClick,
        insertType,
        changeMachine,
        searchMachine,
        getTjdqrPermission,
        getTjrwPermission,
        getJjdqrPermission,
        getTjshPermission,
        isTjshDetail,
        isTjshCancel,
        isTjrwEdit,
        isTjrwFinish,
        sendSwitch,
        visibleZdfb,
        handleOkZdfb,
        handleCancelZdfb,
        typeZdfb,
        aggridFs4,
        aggridFs2,
        aggridFs,
        aggridFs5,
        table1Ref,
        configTable1,
        getMaintenanceProject,
        handleDrawerClose,
        isDispatchWorkDetail,
        baseURL,
        pictures,
      }
    },
    components: { Toolbar, PageTabelLayout, CorporateSectorCascader },
  }
</script>
<style scoped lang="less">
  .Table {
    border-collapse: collapse;
  }

  .Table td,
  .Table th {
    border: 1px solid #ccc;
    padding: 0 5px 0 5px;
    height: 30px;
  }

  .thClass {
    font-size: 16px;
    font-weight: 600;
  }

  .spanClass {
    display: inline-block;
    width: 120px;
  }

  #printform td {
    padding: 5px;
  }

  // :deep(.arco-picker .arco-picker-size-mini){
  //   border: 1pc solid #ccc;
  // }
  :deep(.timeClass) {
    background-color: white;
    border: 1px solid #a29f9f;
  }

  :deep(.arco-picker input) {
    padding-left: 0 !important;
  }

  :deep(.arco-checkbox-disabled .arco-checkbox-label) {
    color: black !important; /* 设置禁用状态下文字的颜色为黑色 */
  }
</style>
